pexpect question....

draghuram at gmail.com draghuram at gmail.com
Tue Jul 5 12:05:35 EDT 2005


Hi,

While I continue to look at the problem, I thought I would post more
details. In a sense, this is more of a UNIX issue.

I have a python script that uses pexpect to spawn a child process (p1).
The python script then goes ahead and does a "tail --pid=p1". Assuming
that I do close(wait=0), P1 completes and gets stuck in zombie status.
The python script is also stuck because "tail" will not return until
zombie P1 goes away. So each is waiting for the other to go away
resulting in a deadlock.

Apparently, when close(wait=0) is done, all that pexpect does is that
it wouldn't call wait() on the spawned process anymore. I was looking
for a solution where pexpect also should be able to tell kernel that it
doesn't care about child process's exit status. Note that this is
different from not doing "wait". I think this can be achieved by
ignoring SIGCLD on SVR4 systems but I am not sure what is the
(expected) behaviour on posix/linux. Unfortunately, only parent process
can control this behaviour. So my questions are two fold.

1) What is the best way (preferably a generic UNIX way) for a parent
process to inform kernel that it is not interested in child process's
exit status?

2) How can this be achieved in pexpect module since it is spawning the
child process in my case.

As I said, this is more of a UNIX question rather than python one.

Thanks,
Raghu.




More information about the Python-list mailing list