mirror of
https://github.com/systemd/systemd.git
synced 2025-03-11 20:58:27 +03:00
fd-util: add new helper close_many_unset()
This commit is contained in:
parent
26f937e576
commit
d3eb74f8f8
@ -99,6 +99,13 @@ void close_many(const int fds[], size_t n_fd) {
|
||||
safe_close(fds[i]);
|
||||
}
|
||||
|
||||
void close_many_unset(int fds[], size_t n_fd) {
|
||||
assert(fds || n_fd <= 0);
|
||||
|
||||
for (size_t i = 0; i < n_fd; i++)
|
||||
fds[i] = safe_close(fds[i]);
|
||||
}
|
||||
|
||||
void close_many_and_free(int *fds, size_t n_fds) {
|
||||
assert(fds || n_fds <= 0);
|
||||
|
||||
|
@ -30,6 +30,7 @@ static inline int safe_close_above_stdio(int fd) {
|
||||
}
|
||||
|
||||
void close_many(const int fds[], size_t n_fd);
|
||||
void close_many_unset(int fds[], size_t n_fd);
|
||||
void close_many_and_free(int *fds, size_t n_fds);
|
||||
|
||||
int fclose_nointr(FILE *f);
|
||||
|
@ -2251,8 +2251,7 @@ void exec_params_serialized_done(ExecParameters *p) {
|
||||
if (!p)
|
||||
return;
|
||||
|
||||
for (size_t i = 0; p->fds && i < p->n_socket_fds + p->n_storage_fds; i++)
|
||||
p->fds[i] = safe_close(p->fds[i]);
|
||||
close_many_unset(p->fds, p->n_socket_fds + p->n_storage_fds);
|
||||
|
||||
p->cgroup_path = mfree(p->cgroup_path);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user