summaryrefslogtreecommitdiff
path: root/namedev.c
diff options
context:
space:
mode:
authorkay.sievers@vrfy.org <kay.sievers@vrfy.org>2004-01-27 00:40:12 -0800
committerGreg KH <gregkh@suse.de>2005-04-26 21:13:19 -0700
commit2a25816ff0079247d7f868621951739e6d58c885 (patch)
tree4af86ed5d0017ae0a89b9abd35151a3b065343b5 /namedev.c
parent8af67a67c2542a9d4eb2371dfba661c65d48d4b6 (diff)
[PATCH] udev - trivial style cleanup
Trivial style cleanup, to be consistent. And add chdir("/") to the daemon so one can umout its filesystem, while we are running :)
Diffstat (limited to 'namedev.c')
-rw-r--r--namedev.c24
1 files changed, 10 insertions, 14 deletions
diff --git a/namedev.c b/namedev.c
index 6b1aa297ea..de7f7c1b88 100644
--- a/namedev.c
+++ b/namedev.c
@@ -332,12 +332,8 @@ static int execute_program(char *path, char *value, int len)
return -1;
}
pid = fork();
- if (pid == -1) {
- dbg("fork failed");
- return -1;
- }
-
- if (pid == 0) {
+ switch(pid) {
+ case 0:
/* child */
close(STDOUT_FILENO);
dup(fds[1]); /* dup write side of pipe to STDOUT */
@@ -353,16 +349,16 @@ static int execute_program(char *path, char *value, int len)
dbg("too many args - %d", i);
args[i] = NULL;
}
- retval = execve(args[0], args, main_envp);
+ retval = execv(args[0], args);
} else {
- retval = execve(path, main_argv, main_envp);
- }
- if (retval != 0) {
- dbg("child execve failed");
- exit(1);
+ retval = execv(path, main_argv);
}
- return -1; /* avoid compiler warning */
- } else {
+ dbg("child execve failed");
+ exit(1);
+ case -1:
+ dbg("fork failed");
+ return -1;
+ default:
/* parent reads from fds[0] */
close(fds[1]);
retval = 0;