home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / unix / programm / 5667 < prev    next >
Encoding:
Internet Message Format  |  1992-12-12  |  1.6 KB

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!sdd.hp.com!think.com!yale.edu!ira.uka.de!math.fu-berlin.de!mailgzrz.TU-Berlin.DE!mailgzrz.tu-berlin.de!nickel
  2. From: nickel@cs.tu-berlin.de (Juergen Nickelsen)
  3. Newsgroups: comp.unix.programmer
  4. Subject: Re: ***  Simple batch-style Unix question
  5. Date: 12 Dec 1992 21:41:31 GMT
  6. Organization: STONE Project, Technical University of Berlin, Germany
  7. Lines: 27
  8. Message-ID: <NICKEL.92Dec12224130@desaster.cs.tu-berlin.de>
  9. References: <1992Dec11.222613.10867@murdoch.acc.Virginia.EDU>
  10. Reply-To: nickel@cs.tu-berlin.de
  11. NNTP-Posting-Host: desaster.cs.tu-berlin.de
  12. In-reply-to: tdh6t@fulton.seas.Virginia.EDU's message of Fri, 11 Dec 1992 22:26:13 GMT
  13. To: 
  14.  
  15. In article <1992Dec11.222613.10867@murdoch.acc.Virginia.EDU>
  16. tdh6t@fulton.seas.Virginia.EDU (Todd #$%!@! Hodes) writes:
  17.  
  18. >         Now... say I've gotten a process ID from grep'ing a
  19. > ps command, and want to send it to a 'kill -9'
  20. >         How do I do this ?
  21. > ps -aux | grep "xv " | sort -2 | awk '{if (NR == 1) print $2;}' |  kill -9
  22. > fails on the last pipe (the kill)
  23. [...]
  24.  
  25. kill(1) does not read its standard input. To issue a kill command, you
  26. have to give the pid to kill as an *argument*.
  27.  
  28. So, instead of "command_that_prints_the_pid | kill" you have to use
  29. the backquote mechanism as in "kill `command_that_prints_the_pid`".
  30.  
  31. BTW, you should use the KILL signal (9) only when absolutely
  32. necessary. Several programs need to do some necessary cleanup before
  33. they terminate; this is impossible when they receive the KILL signal,
  34. since it can't be caught. Use the "softer" signals HUP, TERM, INTR,
  35. QUIT (1, 15, 2, 3) instead whereever possible.
  36.  
  37. --
  38. Juergen Nickelsen
  39.