diff options
author | Jeff Dike <jdike@addtoit.com> | 2006-09-26 02:33:02 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-09-26 11:49:06 -0400 |
commit | 6b7aaad9ba4f2a059a70014be12a921eceebfc47 (patch) | |
tree | d9ba70b160b7df23dea33e5c8e83119ecdca7332 /arch/um | |
parent | 5e1f65a67d76341795ea527d30bfdca03999d46b (diff) |
[PATCH] uml: Fix handling of failed execs of helpers
There were some bugs in handling failures to exec helper programs. errno was
passed back from the child with the wrong sign. It was also ignored. In the
case where it mattered, the errno from the (successful) read in the parent was
used instead.
Signed-off-by: Jeff Dike <jdike@addtoit.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/um')
-rw-r--r-- | arch/um/os-Linux/helper.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/arch/um/os-Linux/helper.c b/arch/um/os-Linux/helper.c index 6987d1d247a2..cd15b9df5b5c 100644 --- a/arch/um/os-Linux/helper.c +++ b/arch/um/os-Linux/helper.c | |||
@@ -42,7 +42,7 @@ static int helper_child(void *arg) | |||
42 | if(data->pre_exec != NULL) | 42 | if(data->pre_exec != NULL) |
43 | (*data->pre_exec)(data->pre_data); | 43 | (*data->pre_exec)(data->pre_data); |
44 | execvp(argv[0], argv); | 44 | execvp(argv[0], argv); |
45 | errval = errno; | 45 | errval = -errno; |
46 | printk("helper_child - execve of '%s' failed - errno = %d\n", argv[0], errno); | 46 | printk("helper_child - execve of '%s' failed - errno = %d\n", argv[0], errno); |
47 | os_write_file(data->fd, &errval, sizeof(errval)); | 47 | os_write_file(data->fd, &errval, sizeof(errval)); |
48 | kill(os_getpid(), SIGKILL); | 48 | kill(os_getpid(), SIGKILL); |
@@ -62,7 +62,7 @@ int run_helper(void (*pre_exec)(void *), void *pre_data, char **argv, | |||
62 | stack = *stack_out; | 62 | stack = *stack_out; |
63 | else stack = alloc_stack(0, __cant_sleep()); | 63 | else stack = alloc_stack(0, __cant_sleep()); |
64 | if(stack == 0) | 64 | if(stack == 0) |
65 | return(-ENOMEM); | 65 | return -ENOMEM; |
66 | 66 | ||
67 | ret = os_pipe(fds, 1, 0); | 67 | ret = os_pipe(fds, 1, 0); |
68 | if(ret < 0){ | 68 | if(ret < 0){ |
@@ -95,16 +95,16 @@ int run_helper(void (*pre_exec)(void *), void *pre_data, char **argv, | |||
95 | /* Read the errno value from the child, if the exec failed, or get 0 if | 95 | /* Read the errno value from the child, if the exec failed, or get 0 if |
96 | * the exec succeeded because the pipe fd was set as close-on-exec. */ | 96 | * the exec succeeded because the pipe fd was set as close-on-exec. */ |
97 | n = os_read_file(fds[0], &ret, sizeof(ret)); | 97 | n = os_read_file(fds[0], &ret, sizeof(ret)); |
98 | if (n < 0) { | 98 | if(n == 0) |
99 | printk("run_helper : read on pipe failed, ret = %d\n", -n); | ||
100 | ret = n; | ||
101 | kill(pid, SIGKILL); | ||
102 | CATCH_EINTR(waitpid(pid, NULL, 0)); | ||
103 | } else if(n != 0){ | ||
104 | CATCH_EINTR(n = waitpid(pid, NULL, 0)); | ||
105 | ret = -errno; | ||
106 | } else { | ||
107 | ret = pid; | 99 | ret = pid; |
100 | else { | ||
101 | if(n < 0){ | ||
102 | printk("run_helper : read on pipe failed, ret = %d\n", | ||
103 | -n); | ||
104 | ret = n; | ||
105 | kill(pid, SIGKILL); | ||
106 | } | ||
107 | CATCH_EINTR(waitpid(pid, NULL, 0)); | ||
108 | } | 108 | } |
109 | 109 | ||
110 | out_close: | 110 | out_close: |