Skip to content

Remove closing of standard file descriptors in the child process

The current forking of the command process closes fd 0, which is the standard input fd. This can cause some applications to fail, like dig (see for instance #19 (closed)). Apart from the fact that this has caused a problem it is actually undefined behaviour in POSIX as described at the end of APPLICATION USAGE in "man 3p close" (https://pubs.opengroup.org/onlinepubs/9699919799/functions/close.html).

Additionally, this merge request also removes the of close() before dup2() for standard output and standard error. While the current behaviour is almost fine, according to "man 3p close", close() followed by dup2() is not atomic and dup2() should be used instead. This is actually the case here, so the call to close() can be safely removed.

This would solve #19 (closed)

Merge request reports

Loading