[NCLUG] Perl/bash SIGINT question

Marcio Luis Teixeira marciot at yahoo.com
Tue Jun 10 07:23:38 MDT 2008


Ah, but I specifically want the children process to get a SIGINT as well. I want the parent shell and all its children to die (my, that sounds bad, doesn't it? One of my college profs told a story of enthusiastically discussing UNIX processes management with a colleague in a restaurant, only to get very odd looks from the other patrons, but I digress...). Is there a way I can persuade the shell to forward the SIGINT to it's children before itself dying? That would be the ideal behavior.

-- Marcio


----- Original Message ----
From: Bob Proulx <bob at proulx.com>
To: nclug at nclug.org
Sent: Tuesday, June 10, 2008 2:48:30 AM
Subject: Re: [NCLUG] Perl/bash SIGINT question

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
_______________________________________________
NCLUG mailing list      NCLUG at nclug.org

To unsubscribe, subscribe, or modify 
your settings, go to: 
http://www.nclug.org/mailman/listinfo/nclug



      


More information about the NCLUG mailing list