It is Friday night and like the idiot I am, I am trying to figure out why pclose() returns -1 in some extremely awful code I wrote months ago, only when running in a machine in South Korea.
How is your night going?
@jamey Yes please!
I have tried a small test to try isolate the problem (that calls popen()/pclose()) but could not reproduce it. Probably something with the larger system.
I have tried strace, but I can't figure out why wait4() (which pclose() calls) returns ECHILD. Clearly the child process has run, because I could read its stdout.
I'm just gonna look for patterns in the said stdout and declare victory for tonight. But I too am curious to know what's going on.
@sajith As I expected, you have tried what I would have!
After checking the Linux man page for waitpid(2), the only other thing I can think of is whether the signal handling action for SIGCHLD is SIG_IGN, which signal(7) says is the default. (I feel like it ought to be possible to check that by digging around in /proc but I can't find anything about signals there.) I don't know how that's supposed to work, but maybe you have to set a signal handler to be able to call wait*?