util-lib: save/restore errno in cleanup calls
We should be careful with errno in cleanup functions, and not alter it under any circumstances. In the safe_close cleanup handlers we are already safe in that regard, but let's add similar protections on other cleanup handlers that invoke system calls. Why bother? Cleanup handlers insert code at function return in non-obvious ways. Hence, code that sets errno and returns should not be confused by us overrding the errno from a cleanup handler. This is a paranoia fix only, I am not aware where this actually mattered in real-life situations.
This commit is contained in:
@@ -796,6 +796,8 @@ void sigkill_wait(pid_t pid) {
|
||||
}
|
||||
|
||||
void sigkill_waitp(pid_t *pid) {
|
||||
PROTECT_ERRNO;
|
||||
|
||||
if (!pid)
|
||||
return;
|
||||
if (*pid <= 1)
|
||||
|
||||
Reference in New Issue
Block a user