1
0
mirror of https://github.com/systemd/systemd.git synced 2025-03-10 16:58:28 +03:00

fd-util: add new helper close_many_unset()

This commit is contained in:
Lennart Poettering 2023-10-18 14:03:36 +02:00
parent 26f937e576
commit d3eb74f8f8
3 changed files with 9 additions and 2 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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);