Skip to content

Commit 4b6f0eb

Browse files
committed
libct/nsenter: save errno in sane_kill
Since sane_kill after a failed read or write, but before reporting the error from that read or write, it may change the errno value in case kill(2) fails. Save and restore the errno around the call to kill. Signed-off-by: Kir Kolyshkin <[email protected]>
1 parent 2e5864c commit 4b6f0eb

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

libcontainer/nsenter/nsexec.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -639,9 +639,14 @@ void join_namespaces(char *nsspec)
639639

640640
static inline int sane_kill(pid_t pid, int signum)
641641
{
642-
if (pid > 0)
643-
return kill(pid, signum);
644-
else
642+
if (pid > 0) {
643+
int ret, saved_errno;
644+
645+
saved_errno = errno;
646+
ret = kill(pid, signum);
647+
errno = saved_errno;
648+
return ret;
649+
} else
645650
return 0;
646651
}
647652

0 commit comments

Comments
 (0)