summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@suse.de>2005-08-28 23:13:14 +0200
committerKay Sievers <kay.sievers@suse.de>2005-08-28 23:13:14 +0200
commitc6303c1316e967ae2c52792b0560ee055ce4276e (patch)
treec30f8ce8a5bcd73a14784504de565ce83f9e5ce9
parentf1ff8d7b4ad1f95385d42c3fa1b2a997b9e6d5f5 (diff)
remove not needed sig_flag for state of signal_pipe
Less internal state is better. And, we don't need to call read() twice with every signal handling. Signed-off-by: Kay Sievers <kay.sievers@suse.de>
-rw-r--r--udevd.c26
1 files changed, 6 insertions, 20 deletions
diff --git a/udevd.c b/udevd.c
index d26d53fe0b..3392eea1a1 100644
--- a/udevd.c
+++ b/udevd.c
@@ -636,8 +636,6 @@ static struct uevent_msg *get_netlink_msg(void)
static void asmlinkage sig_handler(int signum)
{
- int rc;
-
switch (signum) {
case SIGINT:
case SIGTERM:
@@ -653,14 +651,8 @@ static void asmlinkage sig_handler(int signum)
break;
}
- /* if pipe is empty, write to pipe to force select to return,
- * which will wakeup our mainloop
- */
- if (!sig_flag) {
- rc = write(signal_pipe[1], &signum, sizeof(signum));
- if (rc >= 0)
- sig_flag = 1;
- }
+ /* write to pipe, which will wakeup select() in our mainloop */
+ write(signal_pipe[WRITE_END], "", 1);
}
static void udev_done(int pid)
@@ -974,16 +966,10 @@ int main(int argc, char *argv[], char *envp[])
}
/* received a signal, clear our notification pipe */
- if (FD_ISSET(signal_pipe[0], &readfds)) {
- int sig;
- ssize_t rlen;
-
- while(1) {
- rlen = read(signal_pipe[0], &sig, sizeof(sig));
- if (rlen <= 0)
- break;
- }
- sig_flag = 0;
+ if (FD_ISSET(signal_pipe[READ_END], &readfds)) {
+ char buf[256];
+
+ read(signal_pipe[READ_END], &buf, sizeof(buf));
}
/* forked child have returned */