[NCLUG] Perl/bash SIGINT question

Bob Proulx bob at proulx.com
Wed Jun 11 15:08:21 MDT 2008


Marcio Luis Teixeira wrote:
> 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.

I strongly recommend that you find a copy of Advanced Programming in
the UNIX Environment by W. Richard Stevens and read through chapter 9
on Process Relationships.  The book is an excellent tome of wisdom and
I can't recommend it strongly enough.  I feel confident in saying that
you will enjoy reading it.

The topic you are interested in is how process groups work.  For your
job control application you would probably want to launch the jobs in
a separate process group and then send your kill signals to that
process group.  Normally when the tty driver sees control-c and and
sends SIGINT it sends the signal to the foreground process group.
This is how the entire group of processes all get the signal.  Job
control jobs are launched into unique groups and only the current
foreground group is sent the interrupt signal.

This is how BSD job control works in shells and seems to be the
functionality that you are trying to create with your GUI
application.

Bob



More information about the NCLUG mailing list