hep needed with pipes (popen4)

Donn Cave donn at u.washington.edu
Fri Feb 22 17:40:41 EST 2002


Quoth "Darcy Kahle" <dkahle at interactdirect.com>:
...
| I am running a comand using os.popen4().  The command produces output until
| the user hits control-C, at which time, it prints a summary, and exits.  I
| want to send that character down the pipe to it without the user doing so
| (control-c kills the script, by default).  I tried sending "\x003", which to
| the best of my knowledge, is the hex code for it, but it didn't work.

Once the command is behind a pipe, control-C is just data.  You got the
data right, but if you want the same effect as the terminal driver gives
you, deliver a SIGINT to the process (os.kill(pid, signal.SIGINT).)

| If this is not possible, then I could do the same by redirecting the stdin
| to /dev/null, but if I do that at the start, the command will stop
| immediately.

What happens if you close its input pipe?  That's really the ideal way to
tell a process its job is done.

	Donn Cave, donn at u.washington.edu



More information about the Python-list mailing list