diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2021-07-23 10:51:14 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2021-07-23 11:37:44 +0200 |
commit | 9c46228b7deb53d6384545535b37b2844a102b2b (patch) | |
tree | 374cd3c756b534da943ec456b5f6fe8adb96ed25 /src/basic/fd-util.h | |
parent | Merge pull request #20103 from flokli/nsswitch-nss-myhostname (diff) | |
download | systemd-9c46228b7deb53d6384545535b37b2844a102b2b.tar.xz systemd-9c46228b7deb53d6384545535b37b2844a102b2b.zip |
basic/fd-util: sort the 'except' array in place
We need a sorted list of fds to skip over when closing. We would allocate a
copy of the passed array to do the sort. But all callers construct a temporary
array to pass to us, so it is pointless to copy it again.
close_all_fds/safe_fork_full/namespace_fork/fork_agent are changed to pass
a non-const int array. I checked all users, and all callers are fine with
the array being sorted.
The function was returning some number (sometimes 1, sometimes the extent
of the range passed over to close_range(), ???). Anyway, all callers only
check for error, so let's return 0 on success.
Diffstat (limited to 'src/basic/fd-util.h')
-rw-r--r-- | src/basic/fd-util.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/basic/fd-util.h b/src/basic/fd-util.h index 9529a4723d..d3c2944d86 100644 --- a/src/basic/fd-util.h +++ b/src/basic/fd-util.h @@ -56,7 +56,7 @@ DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(DIR*, closedir, NULL); int fd_nonblock(int fd, bool nonblock); int fd_cloexec(int fd, bool cloexec); -int close_all_fds(const int except[], size_t n_except); +int close_all_fds(int except[], size_t n_except); int same_fd(int a, int b); |