home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / unix / shell / 3081 < prev    next >
Encoding:
Internet Message Format  |  1992-07-22  |  1.6 KB

  1. Path: sparky!uunet!mcsun!sun4nl!tuegate.tue.nl!svin02!wsinti01!keesh
  2. From: keesh@wsinti01.info.win.tue.nl (Kees Huizing)
  3. Newsgroups: comp.unix.shell
  4. Subject: How to send a signal to a shell script? (ANSWER)
  5. Message-ID: <3714@svin02.info.win.tue.nl>
  6. Date: 22 Jul 92 12:10:11 GMT
  7. References: <3700@svin02.info.win.tue.nl>
  8. Sender: news@svin02.info.win.tue.nl
  9. Reply-To: keesh@info.win.tue.nl
  10. Lines: 36
  11.  
  12. Thanks to Michael Cook <mcook@merlin.dev.cdx.mot.com>, I know the answer to
  13. my question. 
  14.  
  15. Summary of the problem:
  16. A signal is sent to a shell script with process id 12345 and job number 1 (in
  17. csh) that is currently executing a sleep command.
  18. The signal USR1 seems not to arrive when sent with the command:
  19.  
  20. kill -30 12345
  21.  
  22. It does arrive, however, when sent with
  23.  
  24. kill -30 %1
  25.  
  26. How is this possible, and how can I interrupt the script in case the job number
  27. is not accessible and I don't want to signal the sleep process explicitly?
  28.  
  29. The answer is that the first command sends a signal to the script process
  30. *only*, whereas the second sends it to the process *group* (all processes
  31. dependent on 12345).  As long as the sleep is executing, the shell script
  32. process is suspended and buffers the incoming signals. And the intention was
  33. abort the sleep process and ahndle the signal immediately.
  34.  
  35. Solution: use 
  36.  
  37. kill -30 -12345
  38.  
  39. This to me unknown (SysV?) feature of the kill command sends the signal to
  40. every member of the process group. It works on my Sun. 
  41.  
  42. Thanks to everyone who thought about this, especially to Michael.
  43. Kees
  44.  
  45. -- 
  46. Kees Huizing - Eindhoven Univ of Techn - Dept Math & Comp Sc - The Netherlands
  47. e-mail: keesh@win.tue.nl   telephone: +31-40-474120    fax: +31-40-463992
  48.