chiark / gitweb /
util-lib: save/restore errno in cleanup calls
authorLennart Poettering <lennart@poettering.net>
Wed, 10 Jan 2018 16:21:15 +0000 (17:21 +0100)
committerSven Eden <yamakuzure@gmx.net>
Wed, 30 May 2018 05:50:03 +0000 (07:50 +0200)
commit04d22997d78fe8b0fc608f39c670388955a1466c
tree3ebd112da1105ec07395099de85e13d77246d261
parent843a078dc2b5e0d416c078475466df225d0c99ae
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.
src/basic/fs-util.h
src/basic/process-util.c
src/basic/rm-rf.h