SIGCHLD confuses popen()?

From: Peter C. Chapin (pchapin@ecet.vtc.edu)
Date: Tue Jan 28 2003 - 10:26:49 EST


This may be the wrong place to ask this; if so, feel free to ignore me.

One of my students is building a server program that installs a signal
handler for the SIGCHLD signal. The program creates a child for every
connection and then reaps the children in the signal handler (most likely
while the main loop is blocked in accept()). There are no problems with
this part.

However, the student is also using popen() during the initialization of
the program to spawn a helper process. It happens that he is doing this
after setting up signal handling. Thus when the helper process terminates,
the SIGCHLD handler is run. This apparently confuses popen() because
subsequent attempts to read the helper process's output return nothing.
(I'm assuming the helper process terminates before popen() returns... it
produces only a single line of output and does not need to wait for
anything). However, if the signal handling is temporarly removed, the
output of the helper process can be read fine.

The program works normally as written on our Linux system but displays the
behavior I describe here on Tru64 v5.1A. Is there some Tru64 specific
interaction between signals and popen() that we need to know about? Or
were we just lucky that it worked on Linux?

Peter



This archive was generated by hypermail 2.1.7 : Sat Apr 12 2008 - 10:49:05 EDT