SIGCHLD confuses popen()?

From: Peter C. Chapin <pchapin_at_ecet.vtc.edu>
Date: Tue, 28 Jan 2003 10:26:49 -0500 (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
Received on Tue Jan 28 2003 - 15:27:35 NZDT

This archive was generated by hypermail 2.4.0 : Wed Nov 08 2023 - 11:53:44 NZDT