Question

I have a server application that writes to a popen("myCommand", "w") file descriptor in a separate thread and if the command passed to popen() results in any output to stdout or stderr, the my application exits. However, this is only an issue when my server application was invoked via inetd, if I used ssh to launch the server, it does not have this issue.

Similarly, when my server application reads from a popen("myCommand2", "r") file descriptor in a separate thread and if the command passed to popen() results in any output to stderr (stdin is going to my pipe), the application exits. Again, this only occurs with inetd summoning, not ssh summoning.

Was it helpful?

Solution

you need to close all existed fds of the process before open the pipe, then do i/o redirection. that's because if inetd, the process runs as a daemon.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top