diff options
author | Mark H Weaver <mhw@netris.org> | 2019-05-11 03:47:41 -0400 |
---|---|---|
committer | Mark H Weaver <mhw@netris.org> | 2019-06-18 03:07:27 -0400 |
commit | 521f1ab4709217407496004019c00005d2a82f78 (patch) | |
tree | 435da047351958406de971bfab41feb306c88056 /libguile/boolean.c | |
parent | 3ec7afb2c6906811dcc6f02420ff0f4efc844824 (diff) | |
download | guile-521f1ab4709217407496004019c00005d2a82f78.tar.gz |
open-process: Fix dup(2) and execvp(2) error handling.
Previously, in the case where OUT is 0, or ERR is 0 or 1,
e.g. when (current-error-port) points to STDOUT, the code in
'start_child' to relocate OUT/ERR out of the way to another file
descriptor had multiple bugs:
(1) It neglected to close the original file descriptor.
(2) It checked 'errno' without first checking the return value of
dup(2). This doesn't work because dup(2) leaves 'errno' unchanged
if there's no error.
(3) In case 'errno' contained EINTR, the retry code failed because
OUT (or ERR) was overwritten by the result of the previous failed
dup(2) call.
This commit fixes these problems, as well as another problem with
'execvp' error reporting.
* libguile/posix.c (renumber_file_descriptor): New static helper
function.
(start_child): Use 'renumber_file_descriptor'. If 'execvp' fails, write
the error message to file descriptor 2. Previously, we wrote the error
message to ERR, which was the old file descriptor before being relocated
to 2.
Diffstat (limited to 'libguile/boolean.c')
0 files changed, 0 insertions, 0 deletions