home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 915 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.3 KB

  1. Path: walrus.megabaud.fi!not-for-mail
  2. From: petrin@walrus.megabaud.fi (Petri Nordlund)
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: Re: Breaking another task
  5. Date: 12 Jan 1996 22:35:16 +0200
  6. Organization: Megabaud Oy,Helsinki,Finland
  7. Message-ID: <4d6gm4$r0f@walrus.megabaud.fi>
  8. NNTP-Posting-Host: walrus.megabaud.fi
  9.  
  10. Tom Parker <tparker@amiga3k.codeworks.gen.nz> writes:
  11.  
  12. >I have written a program that puts a window on my editor's screen with a
  13. >button to abort my compiler while it is compiling. It works great, but it does
  14. >it in a very nasty way.
  15. >
  16. >I call executive's ps command, parse its output, and then send it to
  17. >executive's kill command, to kill my smake and all its subtasks.
  18.  
  19.   Are you using the PGRP-option (process group) of Kill? You can
  20.   kill smake and its subtasks by issuing the command:
  21.  
  22.     Kill PGRP=<PID of smake>
  23.  
  24. >What i would like to know, is how do i do what ps & kill do. At the very least
  25. >i want to find the task structure of the compiler, so i can signal it, but i
  26. >would like to be able to kill all the subtasks of smake, and smake itself,
  27. >rather than single out the compiler.
  28.  
  29.   It's not very easy. You'll first have to find the smake-task, but
  30.   you can't use exec.library's FindTask()-function, because the task
  31.   name is not "smake". So you'll have to manually browse Exec's
  32.   tasklists and for each task, check if it's a process. If it is,
  33.   check if it has a CLI-structure (pr_Cli). You'll find the CLI command
  34.   name in the cli_CommandName field, which is a BSTR, i.e. the first byte
  35.   is the string length and the string is not NULL terminated.
  36.  
  37.   When you have the task, you can kill it with Signal()ing it, but
  38.   you can't kill the subtasks, because Exec doesn't currently maintain
  39.   a child-parent relationships of tasks. Executive does this by patching
  40.   AddTask() and RemTask().
  41.  
  42. >I don't mind using executive's functions, if they will do this easier than the
  43. >normal system functions.
  44.  
  45.   I could add support to SysInfo.library for killing process groups,
  46.   currently it can only renice process groups.
  47. -- 
  48.                                       __
  49.  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~///~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  50.        Petri Nordlund             __///         petrin@megabaud.fi
  51.  ---------------------------------\XX/----------------------------------
  52.