basic/fd-util: sort the 'except' array in place
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 23 Jul 2021 08:51:14 +0000 (10:51 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 23 Jul 2021 09:37:44 +0000 (11:37 +0200)
commit9c46228b7deb53d6384545535b37b2844a102b2b
tree374cd3c756b534da943ec456b5f6fe8adb96ed25
parentbecbc6dfa86a2be4ac30ec117d103e5fa62efa72
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.
src/basic/fd-util.c
src/basic/fd-util.h
src/basic/process-util.c
src/basic/process-util.h