Help needed with Popen2
Alwyn Schoeman
alwyns at prism.co.za
Wed Aug 23 03:49:40 EDT 2000
Hi,
I have an application that uses popen2 to spawn a tail -f process on a
logfile. The application then does some processing on the output. I have an
alarm set which checks for a logfile rollover every 30 minutes. If a new
logfile exists, it kills the old tail and starts a new one on the new file.
On linux the os.kill(pid,15) "works" by creating a zombie process of the old
tail, as soon as another zombie is created I guess the old one is recycled by
the OS because there is always only one zombie process.
The problem is on Solaris. For some reason os.kill(pid,15) does no damage on
the tail process. The popen2 starts 2 processes: /bin/sh -c tail -f logfile
and tail -f logfile, the last being the child of the shell. If I kill the
/bin/sh the tail obviously becomes the child of the init process.
Now at last the question: I know that you can do something like /bin/sh -c
exec tail -f logfile, I don't know if it works, BUT will it work to replace the
/bin/sh -c tail -f logfile in popen2 TO /bin/sh -c exec tail -f logfile?
Will it mean that if I kill the pid that the fork returns, it will terminate
all processes related to the older logfile?
Thank you
Alwyn Schoeman
More information about the Python-list
mailing list