🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix.shell
Article #99

How to send a signal to a shell script? (ANSWER)

#99
From: Kees Huizing
Date: Wed, 22 Jul 1992 12:10
36 lines
1733 bytes
Thanks to Michael Cook <mcook@merlin.dev.cdx.mot.com>, I know the answer to
my question. 

Summary of the problem:
A signal is sent to a shell script with process id 12345 and job number 1 (in
csh) that is currently executing a sleep command.
The signal USR1 seems not to arrive when sent with the command:

kill -30 12345

It does arrive, however, when sent with

kill -30 %1

How is this possible, and how can I interrupt the script in case the job number
is not accessible and I don't want to signal the sleep process explicitly?

The answer is that the first command sends a signal to the script process
*only*, whereas the second sends it to the process *group* (all processes
dependent on 12345).  As long as the sleep is executing, the shell script
process is suspended and buffers the incoming signals. And the intention was
abort the sleep process and ahndle the signal immediately.

Solution: use 

kill -30 -12345

This to me unknown (SysV?) feature of the kill command sends the signal to
every member of the process group. It works on my Sun. 

Thanks to everyone who thought about this, especially to Michael.
Kees

-- 
Kees Huizing - Eindhoven Univ of Techn - Dept Math & Comp Sc - The Netherlands
e-mail: keesh@win.tue.nl   telephone: +31-40-474120    fax: +31-40-463992
Technical Details
Message-ID: <3714@svin02.info.win.tue.nl>
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!sun4nl!tuegate.tue.nl!svin02!wsinti01!keesh
References: <3700@svin02.info.win.tue.nl>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!sun4nl!tuegate.tue.nl!svin02!wsinti01!keesh
From: keesh@wsinti01.info.win.tue.nl (Kees Huizing)
Newsgroups: comp.unix.shell
Subject: How to send a signal to a shell script? (ANSWER)
Message-ID: <3714@svin02.info.win.tue.nl>
Date: 22 Jul 92 12:10:11 GMT
References: <3700@svin02.info.win.tue.nl>
Sender: news@svin02.info.win.tue.nl
Reply-To: keesh@info.win.tue.nl
Lines: 36