summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Vlasov <vsu@altlinux.ru>2007-01-21 22:51:53 +0100
committerKay Sievers <kay.sievers@vrfy.org>2007-01-21 22:51:53 +0100
commitff2eecef88733e669ff5a43083534b32b435e2b0 (patch)
tree5a1abab1e3e0f9ea204f86e049a9f0275a736991
parentede9b541712f0f7366f5481d55f5d56d0e47fcc8 (diff)
udevd: init signal pipe before daemonizing
-rw-r--r--udevd.c58
1 files changed, 29 insertions, 29 deletions
diff --git a/udevd.c b/udevd.c
index 79465a1da0..8c550d38aa 100644
--- a/udevd.c
+++ b/udevd.c
@@ -1006,6 +1006,35 @@ int main(int argc, char *argv[], char *envp[])
goto exit;
}
+ /* setup signal handler pipe */
+ retval = pipe(signal_pipe);
+ if (retval < 0) {
+ err("error getting pipes: %s", strerror(errno));
+ goto exit;
+ }
+
+ retval = fcntl(signal_pipe[READ_END], F_GETFL, 0);
+ if (retval < 0) {
+ err("error fcntl on read pipe: %s", strerror(errno));
+ goto exit;
+ }
+ retval = fcntl(signal_pipe[READ_END], F_SETFL, retval | O_NONBLOCK);
+ if (retval < 0) {
+ err("error fcntl on read pipe: %s", strerror(errno));
+ goto exit;
+ }
+
+ retval = fcntl(signal_pipe[WRITE_END], F_GETFL, 0);
+ if (retval < 0) {
+ err("error fcntl on write pipe: %s", strerror(errno));
+ goto exit;
+ }
+ retval = fcntl(signal_pipe[WRITE_END], F_SETFL, retval | O_NONBLOCK);
+ if (retval < 0) {
+ err("error fcntl on write pipe: %s", strerror(errno));
+ goto exit;
+ }
+
/* parse the rules and keep them in memory */
sysfs_init();
udev_rules_init(&rules, 1);
@@ -1062,35 +1091,6 @@ int main(int argc, char *argv[], char *envp[])
close(fd);
}
- /* setup signal handler pipe */
- retval = pipe(signal_pipe);
- if (retval < 0) {
- err("error getting pipes: %s", strerror(errno));
- goto exit;
- }
-
- retval = fcntl(signal_pipe[READ_END], F_GETFL, 0);
- if (retval < 0) {
- err("error fcntl on read pipe: %s", strerror(errno));
- goto exit;
- }
- retval = fcntl(signal_pipe[READ_END], F_SETFL, retval | O_NONBLOCK);
- if (retval < 0) {
- err("error fcntl on read pipe: %s", strerror(errno));
- goto exit;
- }
-
- retval = fcntl(signal_pipe[WRITE_END], F_GETFL, 0);
- if (retval < 0) {
- err("error fcntl on write pipe: %s", strerror(errno));
- goto exit;
- }
- retval = fcntl(signal_pipe[WRITE_END], F_SETFL, retval | O_NONBLOCK);
- if (retval < 0) {
- err("error fcntl on write pipe: %s", strerror(errno));
- goto exit;
- }
-
/* set signal handlers */
memset(&act, 0x00, sizeof(struct sigaction));
act.sa_handler = (void (*)(int)) sig_handler;