aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/um/drivers/net_user.c4
-rw-r--r--arch/um/os-Linux/helper.c10
2 files changed, 8 insertions, 6 deletions
diff --git a/arch/um/drivers/net_user.c b/arch/um/drivers/net_user.c
index 0e2f06187ea7..0a7786e00cfb 100644
--- a/arch/um/drivers/net_user.c
+++ b/arch/um/drivers/net_user.c
@@ -182,7 +182,9 @@ static int change_tramp(char **argv, char *output, int output_len)
182 pe_data.stdout = fds[1]; 182 pe_data.stdout = fds[1];
183 pid = run_helper(change_pre_exec, &pe_data, argv, NULL); 183 pid = run_helper(change_pre_exec, &pe_data, argv, NULL);
184 184
185 read_output(fds[0], output, output_len); 185 if (pid > 0) /* Avoid hang as we won't get data in failure case. */
186 read_output(fds[0], output, output_len);
187
186 os_close_file(fds[0]); 188 os_close_file(fds[0]);
187 os_close_file(fds[1]); 189 os_close_file(fds[1]);
188 190
diff --git a/arch/um/os-Linux/helper.c b/arch/um/os-Linux/helper.c
index 6490a4ff40ac..6987d1d247a2 100644
--- a/arch/um/os-Linux/helper.c
+++ b/arch/um/os-Linux/helper.c
@@ -43,7 +43,7 @@ static int helper_child(void *arg)
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("execvp 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);
49 return(0); 49 return(0);
@@ -92,15 +92,15 @@ int run_helper(void (*pre_exec)(void *), void *pre_data, char **argv,
92 close(fds[1]); 92 close(fds[1]);
93 fds[1] = -1; 93 fds[1] = -1;
94 94
95 /*Read the errno value from the child.*/ 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 n = os_read_file(fds[0], &ret, sizeof(ret)); 97 n = os_read_file(fds[0], &ret, sizeof(ret));
97 if(n < 0){ 98 if (n < 0) {
98 printk("run_helper : read on pipe failed, ret = %d\n", -n); 99 printk("run_helper : read on pipe failed, ret = %d\n", -n);
99 ret = n; 100 ret = n;
100 kill(pid, SIGKILL); 101 kill(pid, SIGKILL);
101 CATCH_EINTR(waitpid(pid, NULL, 0)); 102 CATCH_EINTR(waitpid(pid, NULL, 0));
102 } 103 } else if(n != 0){
103 else if(n != 0){
104 CATCH_EINTR(n = waitpid(pid, NULL, 0)); 104 CATCH_EINTR(n = waitpid(pid, NULL, 0));
105 ret = -errno; 105 ret = -errno;
106 } else { 106 } else {