On Wed, Nov 9, 2011 at 2:25 PM, Anton Kovalenko <anton@...> wrote:
> nicolas edel <nicolas.edel@...> writes:
>> Ok, I had a look at the source code; This is due to C code where only
>> the fork syscall is checked but not the exec. Also checking the latter
>> would avoid calling the make-process function by returning -1 if fork
>> *or* exec have failed and signal an error with an appropriate
>> description .
> It's not that easy: when exec fails, it fails in a child process that
> was already created, and we can't return /anything/ to parent (or signal
> an error in parent) at that point.
> One possible solution is to create a pipe before fork(), set FD_CLOEXEC
> on its write side, and wait in parent while its read side is closed.
> If exec*() succeeds, there would be no data; if it fails, our child
> process can write something to his end of pipe, indicating the failure
> (and probably a reason for it).
That's indeed the usual way to implement it, and this is what I would
do if such a patch could be integrated. I did some tests using a
simple C program and it works. But as far as I can't test it (and even
compile it) on other OS than Linux/FreeBSD, I would like to know if
there is a way to compile/test before any patch proposal.