pty/fork and SIGINT

Brian Sturk bsturk at
Tue Dec 18 23:33:19 EST 2001

<I'm posting this here in addition to accidentally emailing it
 to the previous poster>  ooops

> Works for me.  I'm running BeOS right now, so that's where I tried it,
> but I imagine it will work under UNIX too.
> You have a big problem there - as you recognize, with a big script and
> an unusual operating environment and all, it's hard to say where it's
> going wrong.  You need to simplify.  You can run ping behind a pty and
> print out the output in a few lines of code;  now use posix.kill to
> deliver your signal to the ping process.  Works?  Hm.  Run a simple
> sleep process from vim, let it die naturally.  That working?  Kill it,
> still works like you expect?  Etc.

Thanks for your response.

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. 

I had tried as a workaround to get a list of the running processes
on the current pty (usually only the shell and another app, ie ping)
and give the user a list to choose from which to send the SIGINT to.
However, the fd returned from pty.fork always returns /dev/ptmx which
from what I've read seems to be the "master".  I'm also too new to
this particular area of programming so how to use openpty() isn't obvious
to me (although I'm looking).

I've been reading posts in here as well as in the other programming groups
and my Stevens book on Unix programming covers signals and pty
very thoroughly. All have been very helpful.

For the most part applications run fine within this environment, both
interactive and non interactive. Control signals are one of the more
exotic things I'm trying to support.  On Windows however, I am using
popen and cannot seem to run interactive programs at all. This, from
what I've been told has to do with line buffering.

> When you have a simple 20 line script that we can run and see the
> same problem for ourselves, then you can hope for help.  (But I bet
> you'll find the problem on your own in the process.)

thanks again.

| Brian M. Sturk - \ C/C++ |  .>   )\,^a__
|--------------------------|  bsturk at   | Java | (  _ _)/ /-." ~
| `---------------------------`------|  `( )_ )/
| Telengard Technologies Inc. -  NT/*nix UI & device drivers  | _<_s_<_s

More information about the Python-list mailing list