Jerry Feldman wrote:
It is tedious to do this, but you really need to track every open(2) and close(2). You also have a complicated system where you are using BOTH threads and forks.
Yeah, I'm beginning to wonder if I should be reworking that setup. It would involve running another daemon to repeatedly run the otherwise fork()ed program. But I'm not too keen on running yet another daemon just for that.
Be very careful of using fork(2) from threads. To quote from Dave Butenhof, "Avoid using forkin a threaded program (if you can) unless you intend to exec a new program immediately".
That is pretty much what I do : 1. fiddle with the pipe for input/output. Closing what I don't need, dup2() onto stdout. 2. Redirect stdin and stderr to files. 3. chdir() to working dir. 4. execv. /Per Jessen, Zürich