mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
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. While at it, - change the code to return early; - don't return kill return value as no one is using it, and the errno value no longer correlates. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
@@ -637,12 +637,14 @@ void join_namespaces(char *nsspec)
|
||||
__close_namespaces(to_join, joined, ns_list, ns_len);
|
||||
}
|
||||
|
||||
static inline int sane_kill(pid_t pid, int signum)
|
||||
static inline void sane_kill(pid_t pid, int signum)
|
||||
{
|
||||
if (pid > 0)
|
||||
return kill(pid, signum);
|
||||
else
|
||||
return 0;
|
||||
if (pid <= 0)
|
||||
return;
|
||||
|
||||
int saved_errno = errno;
|
||||
kill(pid, signum);
|
||||
errno = saved_errno;
|
||||
}
|
||||
|
||||
void try_unshare(int flags, const char *msg)
|
||||
|
||||
Reference in New Issue
Block a user