summaryrefslogtreecommitdiff
path: root/src/util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2011-03-11 00:52:13 +0100
committerLennart Poettering <lennart@poettering.net>2011-03-11 00:52:31 +0100
commit720ce21d444f6497299c4c99a76fda546b06716a (patch)
tree290218a959a99f46c65e25c3717860438b05bdef /src/util.c
parentb997812119882f95a9456ce15667b0545be8e417 (diff)
util: close all fds before freezing execution
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/util.c b/src/util.c
index c02b39e0ad..c9366c4a39 100644
--- a/src/util.c
+++ b/src/util.c
@@ -1815,8 +1815,9 @@ int close_all_fds(const int except[], unsigned n_except) {
if (ignore_file(de->d_name))
continue;
- if ((r = safe_atoi(de->d_name, &fd)) < 0)
- goto finish;
+ if (safe_atoi(de->d_name, &fd) < 0)
+ /* Let's better ignore this, just in case */
+ continue;
if (fd < 3)
continue;
@@ -1839,16 +1840,13 @@ int close_all_fds(const int except[], unsigned n_except) {
continue;
}
- if ((r = close_nointr(fd)) < 0) {
+ if (close_nointr(fd) < 0) {
/* Valgrind has its own FD and doesn't want to have it closed */
- if (errno != EBADF)
- goto finish;
+ if (errno != EBADF && r == 0)
+ r = -errno;
}
}
- r = 0;
-
-finish:
closedir(d);
return r;
}
@@ -3619,6 +3617,10 @@ int wait_for_terminate_and_warn(const char *name, pid_t pid) {
}
void freeze(void) {
+
+ /* Make sure nobody waits for us on a socket anymore */
+ close_all_fds(NULL, 0);
+
sync();
for (;;)