pty/fork and SIGINT

Donn Cave donn at u.washington.edu
Wed Dec 19 11:56:27 EST 2001


Quoth bsturk at news.rcn.com (Brian Sturk):
...
| I think you may have misunderstood my question.  Sending the signal
| to ping works fine, but sending it to the parent pid, which is all
| I have after executing pty.fork() doesn't "forward" the signal.
| I should probably have been more explicit.  I guess I was expecting
| the behavior I see when I run in an interactive shell when I sent the signal
| to the controlling shell. 

If you use the terminal driver to send a signal (like ctrl-C -> SIGINT),
it goes to the foreground process group.  (Assuming Berkeley job control.)
That may look like forwarding, but really is more of a limited broadcast.
I believe pty.fork() is deliberately taking your child process out of
reach of this, by putting the child process in a new process group with
the slave tty as controlling terminal.  You may be able to get it back
afterwards with posix.setpgid().  If that works, the child process will
still ignore signals sent like posix.kill(posix.getpid(), sig), but you
could expect posix.kill(-posix.getpid(), sig) to reach it, if negative
pid means process group in this context on your platform.

	Donn Cave, donn at u.washington.edu



More information about the Python-list mailing list