diff options
author | Iain Sandoe <iain@sandoe.co.uk> | 2024-02-16 14:42:53 +0000 |
---|---|---|
committer | Iain Sandoe <iain@sandoe.co.uk> | 2024-02-19 20:13:30 +0000 |
commit | 20e57660e64eab7c9ef0f2dd25f3088835f8f44f (patch) | |
tree | cfb9ee449bfedba4541a2e2120b07e90b1441161 /libiberty/pex-unix.c | |
parent | 2322b6dd4a8b0b0a771a696368eefadc7be24ddc (diff) | |
download | gcc-20e57660e64eab7c9ef0f2dd25f3088835f8f44f.zip gcc-20e57660e64eab7c9ef0f2dd25f3088835f8f44f.tar.gz gcc-20e57660e64eab7c9ef0f2dd25f3088835f8f44f.tar.bz2 |
libiberty: Fix error return value in pex_unix_exec_child [PR113957].
r14-5310-g879cf9ff45d940 introduced some new handling for spawning sub
processes. The return value from the generic exec_child is examined
and needs to be < 0 to signal an error. However, the unix flavour of
this routine is returning the PID value set from the posix_spawn{p}.
This latter value is undefined per the manual pages for both Darwin
and Linux, and it seems Darwin, at least, sets the value to some
usually positive number (presumably the PID that would have been used
if the fork had succeeded).
The fix proposed here is to set the pid = -1 in the relevant error
paths.
PR other/113957
libiberty/ChangeLog:
* pex-unix.c (pex_unix_exec_child): Set pid = -1 in the error
paths, since that is used to signal an erroneous outcome for
the routine.
Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
Diffstat (limited to 'libiberty/pex-unix.c')
-rw-r--r-- | libiberty/pex-unix.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/libiberty/pex-unix.c b/libiberty/pex-unix.c index af98062..f3a1cc9 100644 --- a/libiberty/pex-unix.c +++ b/libiberty/pex-unix.c @@ -695,6 +695,7 @@ pex_unix_exec_child (struct pex_obj *obj ATTRIBUTE_UNUSED, { *err = ret; *errmsg = "posix_spawnp"; + pid = -1; /* The value of pid is unspecified on failure. */ goto exit; } } @@ -705,6 +706,7 @@ pex_unix_exec_child (struct pex_obj *obj ATTRIBUTE_UNUSED, { *err = ret; *errmsg = "posix_spawn"; + pid = -1; goto exit; } } |