summaryrefslogtreecommitdiff
path: root/udevd.c
diff options
context:
space:
mode:
authorkay.sievers@vrfy.org <kay.sievers@vrfy.org>2004-01-23 04:01:09 -0800
committerGreg KH <gregkh@suse.de>2005-04-26 21:13:18 -0700
commit90c210eb6bfc2ae294202fffb080315f3c47a57b (patch)
tree9db88ddcf3760d8911ac8dd2959f4715c058e00c /udevd.c
parent034f35d7e634d3900c32e58e791bf631f30a1e57 (diff)
[PATCH] fix udevd exec
Sorry, some code is missing. Here is a fix to make the exec functional.
Diffstat (limited to 'udevd.c')
-rw-r--r--udevd.c33
1 files changed, 31 insertions, 2 deletions
diff --git a/udevd.c b/udevd.c
index 08dede36ee..6af265a389 100644
--- a/udevd.c
+++ b/udevd.c
@@ -24,6 +24,7 @@
#include <sys/types.h>
#include <sys/ipc.h>
+#include <sys/wait.h>
#include <sys/msg.h>
#include <signal.h>
#include <unistd.h>
@@ -49,6 +50,7 @@ static int timeout = 0;
static struct hotplug_msg *head = NULL;
static char exec_program[100];
+
static void sig_handler(int signum)
{
dbg("caught signal %d", signum);
@@ -104,13 +106,40 @@ static void dump_msg(struct hotplug_msg *pmsg)
pmsg->seqnum, pmsg->action, pmsg->devpath, pmsg->subsystem);
}
-static void dispatch_msg(struct hotplug_msg *pmsg)
+static int dispatch_msg(struct hotplug_msg *pmsg)
{
+ pid_t pid;
+ char *argv[3];
+ int retval;
+ extern char **environ;
+
dump_msg(pmsg);
dbg("exec '%s'", exec_program);
+
setenv("ACTION", pmsg->action, 1);
setenv("DEVPATH", pmsg->devpath, 1);
- execl(exec_program, pmsg->subsystem);
+
+ argv[0] = exec_program;
+ argv[1] = pmsg->subsystem;
+ argv[2] = NULL;
+
+ pid = fork();
+ switch (pid) {
+ case 0:
+ retval = execve(argv[0], argv, environ);
+ if (retval != 0) {
+ dbg("child execve failed");
+ exit(1);
+ }
+ break;
+ case -1:
+ dbg("fork failed");
+ return -1;
+ default:
+ wait(0);
+ break;
+ }
+ return 0;
}
static void reset_timer(void)