I am trying to debug something at work, and I must admit, I'm no UNIX
expert. I'm stumped and I thought I'd see if anyone in the community
has an idea. It's a pretty simple operation that does simple commands
like cksum, scp, and chmod with a pipe. The code uses popen to open a
pipe and run a command. It does this so it can get the result of the
command and put it in a log. The string returned from the command is
valid, so the popen command properly executed the command. However,
when pclose is run, the return code is always -1 and the errno is 10
(no child process).
What's weird is that this same code runs fine on all the other
environments we have set up, even on servers that have the same OS and
version. The server that this is failing on is Sun 5.9.
Everything I have read about pclose failing like this has to do with
complicated multithreaded cases, but in this case the only processes
being called are simple commands that execute immediately. Has anyone
seen anything like this? Someone else set up this environment, are
there any settings I should check that might make the environment do
this? Thanks
Solution:
Does your application contain modify the disposition of the SIGCHLD
signal? If so, this could interfere with popen's ability to wait for
the shell to exit.