-[ Tue, Aug 30, 2011 at 05:55:22PM +0200, Ludovic Courtès ]---- > Like in C, it???s up to the application to close those ports that it > considers worth closing upon exec.
I was under the impression that the idiom was to close all files before execing a coprocess, but I just checked POSIX popen, R.Stevens and libslack and none does that. Well, the lib I'm used to does that and it felt natural to do so that I erroneously assumed it was a mandated behavior (so that running a coprocess is similar to running a program from a shell). OK then, so it's not a bug and I have to live with this behavior (BTW, if anyone knows the rational behind this, I would be glad to know). > If what you want is to close every FD from 3 to ???, then the typical way > to do this is to loop over those numbers and call close(2) (that???s how > libdaemon and similar tools do that.) Except that, as previously discussed in another thread, there is no easy way to do that between the fork and the exec (since I don't want to actually close these files in the main program that starts the pipe). Anyway, what about the other bugs? Is there anything I could do to advance the thread-safety issue for instance?