[NCLUG] Perl/bash SIGINT question
Bob Proulx
bob at proulx.com
Tue Jun 10 02:48:30 MDT 2008
Marcio Luis Teixeira wrote:
> I've gotten it mostly to work, except for the case in which I am
> running a local script. In that case, the SIGINT is being
> ignored.
SIGINT is being sent to the shell interpreting the script but not to
process children. The sleep is a child process and isn't getting
killed. Bash is handling SIGINT specially.
If you change to using SIGHUP you will see that the shell exits
immediately. However that casts the sleep loose, it continues to run,
its parent becomes init process id 1, and it continues to run.
Children processes of children processes are not killed.
> As prepared some example code to post here, I found out
> that a workaround is to "ssh" to "localhost", which is probably good
> enough what I need to do, but it's sort of hacky.
That works because ssh is not bash and doesn't handle SIGINT
specially. Try running the test script with /bin/csh and you will
find that things behave differently.
> I was curious if anyone here had any insight why "runCommand(3,
> ...)" below does not work, while "runCommand(5, ...)" does. Ideally,
> I would like to make it so 3 works.
The easiest thing to do would be to use SIGHUP.
Bob
More information about the NCLUG
mailing list