aboutsummaryrefslogtreecommitdiffstats
path: root/src/libenvexec
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2026-01-01 13:47:45 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2026-01-01 13:47:45 +0000
commite99182dab3093f1645f9e4ff216aa752d7443fb1 (patch)
tree175a373c32a58783edd41901d4baf6e68626c7ec /src/libenvexec
parent45137c6466050c9468931713a7504eae3d08bfce (diff)
downloadskalibs-e99182dab3093f1645f9e4ff216aa752d7443fb1.tar.gz
Save/restore errno in all safe wrappers
Diffstat (limited to 'src/libenvexec')
-rw-r--r--src/libenvexec/cspawn.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/libenvexec/cspawn.c b/src/libenvexec/cspawn.c
index a6e1cc1..73efa0d 100644
--- a/src/libenvexec/cspawn.c
+++ b/src/libenvexec/cspawn.c
@@ -125,8 +125,10 @@ static inline pid_t cspawn_workaround (pid_t pid, int const *p)
if (r == -1) return 0 ;
if (r) return (errno = EILSEQ, 0) ; /* child wrote, wtf */
+ int se = errno ;
do e = waitid(P_PID, pid, &si, WEXITED | WNOHANG | WNOWAIT) ;
while (e == -1 && errno == EINTR) ;
+ errno = se ;
if (e == -1) return pid ; /* we're in trouble, but don't leak a child */
if (!si.si_pid) return pid ; /* child is running */
if (si.si_code != CLD_EXITED || si.si_status != 127) return pid ; /* child died after execve(), let caller handle it */