Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 74967
b: refs/heads/master
c: 4dbed85
h: refs/heads/master
i:
  74965: a03e16b
  74963: 2e954de
  74959: af27bcc
v: v3
  • Loading branch information
Stanislaw Gruszka authored and Linus Torvalds committed Dec 18, 2007
1 parent 74387cb commit 944fadb
Show file tree
Hide file tree
Showing 13 changed files with 51 additions and 57 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 5867a78f41f84e5388448da62c183255dc22601f
refs/heads/master: 4dbed85a35ed37d9608f4f32e5d69efa775d6223
2 changes: 1 addition & 1 deletion trunk/arch/um/drivers/net_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ static int change_tramp(char **argv, char *output, int output_len)
close(fds[1]);

if (pid > 0)
CATCH_EINTR(err = waitpid(pid, NULL, 0));
helper_wait(pid, 0, "change_tramp");
return pid;
}

Expand Down
12 changes: 2 additions & 10 deletions trunk/arch/um/drivers/slip_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ static int slip_tramp(char **argv, int fd)
{
struct slip_pre_exec_data pe_data;
char *output;
int status, pid, fds[2], err, output_len;
int pid, fds[2], err, output_len;

err = os_pipe(fds, 1, 0);
if (err < 0) {
Expand Down Expand Up @@ -109,15 +109,7 @@ static int slip_tramp(char **argv, int fd)
read_output(fds[0], output, output_len);
printk("%s", output);

CATCH_EINTR(err = waitpid(pid, &status, 0));
if (err < 0)
err = errno;
else if (!WIFEXITED(status) || (WEXITSTATUS(status) != 0)) {
printk(UM_KERN_ERR "'%s' didn't exit with status 0\n", argv[0]);
err = -EINVAL;
}
else err = 0;

err = helper_wait(pid, 0, argv[0]);
close(fds[0]);

out_free:
Expand Down
15 changes: 3 additions & 12 deletions trunk/arch/um/drivers/slirp_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ static int slirp_open(void *data)
static void slirp_close(int fd, void *data)
{
struct slirp_data *pri = data;
int status,err;
int err;

close(fd);
close(pri->slave);
Expand All @@ -98,18 +98,9 @@ static void slirp_close(int fd, void *data)
"(%d)\n", pri->pid, errno);
}
#endif

CATCH_EINTR(err = waitpid(pri->pid, &status, WNOHANG));
if (err < 0) {
printk(UM_KERN_ERR "slirp_close: waitpid returned %d\n", errno);
return;
}

if (err == 0) {
printk(UM_KERN_ERR "slirp_close: process %d has not exited\n",
pri->pid);
err = helper_wait(pri->pid, 1, "slirp_close");
if (err < 0)
return;
}

pri->pid = -1;
}
Expand Down
3 changes: 1 addition & 2 deletions trunk/arch/um/drivers/ubd_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ int start_io_thread(unsigned long sp, int *fd_out)
goto out_close;
}

pid = clone(io_thread, (void *) sp, CLONE_FILES | CLONE_VM | SIGCHLD,
NULL);
pid = clone(io_thread, (void *) sp, CLONE_FILES | CLONE_VM, NULL);
if(pid < 0){
err = -errno;
printk("start_io_thread - clone failed : errno = %d\n", errno);
Expand Down
2 changes: 1 addition & 1 deletion trunk/arch/um/include/os.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ extern int execvp_noalloc(char *buf, const char *file, char *const argv[]);
extern int run_helper(void (*pre_exec)(void *), void *pre_data, char **argv);
extern int run_helper_thread(int (*proc)(void *), void *arg,
unsigned int flags, unsigned long *stack_out);
extern int helper_wait(int pid);
extern int helper_wait(int pid, int nohang, char *pname);


/* tls.c */
Expand Down
4 changes: 2 additions & 2 deletions trunk/arch/um/os-Linux/aio.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ static int init_aio_24(void)
goto out_close_pipe;

err = run_helper_thread(not_aio_thread, NULL,
CLONE_FILES | CLONE_VM | SIGCHLD, &aio_stack);
CLONE_FILES | CLONE_VM, &aio_stack);
if (err < 0)
goto out_close_pipe;

Expand Down Expand Up @@ -254,7 +254,7 @@ static int init_aio_26(void)
}

err = run_helper_thread(aio_thread, NULL,
CLONE_FILES | CLONE_VM | SIGCHLD, &aio_stack);
CLONE_FILES | CLONE_VM, &aio_stack);
if (err < 0)
return err;

Expand Down
10 changes: 2 additions & 8 deletions trunk/arch/um/os-Linux/drivers/ethertap_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ static int etap_tramp(char *dev, char *gate, int control_me,
int control_remote, int data_me, int data_remote)
{
struct etap_pre_exec_data pe_data;
int pid, status, err, n;
int pid, err, n;
char version_buf[sizeof("nnnnn\0")];
char data_fd_buf[sizeof("nnnnnn\0")];
char gate_buf[sizeof("nnn.nnn.nnn.nnn\0")];
Expand Down Expand Up @@ -131,13 +131,7 @@ static int etap_tramp(char *dev, char *gate, int control_me,
}
if (c != 1) {
printk(UM_KERN_ERR "etap_tramp : uml_net failed\n");
err = -EINVAL;
CATCH_EINTR(n = waitpid(pid, &status, 0));
if (n < 0)
err = -errno;
else if (!WIFEXITED(status) || (WEXITSTATUS(status) != 1))
printk(UM_KERN_ERR "uml_net didn't exit with "
"status 1\n");
err = helper_wait(pid, 0, "uml_net");
}
return err;
}
Expand Down
2 changes: 1 addition & 1 deletion trunk/arch/um/os-Linux/drivers/tuntap_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ static int tuntap_open_tramp(char *gate, int *fd_out, int me, int remote,
"errno = %d\n", errno);
return err;
}
CATCH_EINTR(waitpid(pid, NULL, 0));
helper_wait(pid, 0, "tuntap_open_tramp");

cmsg = CMSG_FIRSTHDR(&msg);
if (cmsg == NULL) {
Expand Down
38 changes: 27 additions & 11 deletions trunk/arch/um/os-Linux/helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ int run_helper(void (*pre_exec)(void *), void *pre_data, char **argv)
data.fd = fds[1];
data.buf = __cant_sleep() ? kmalloc(PATH_MAX, UM_GFP_ATOMIC) :
kmalloc(PATH_MAX, UM_GFP_KERNEL);
pid = clone(helper_child, (void *) sp, CLONE_VM | SIGCHLD, &data);
pid = clone(helper_child, (void *) sp, CLONE_VM, &data);
if (pid < 0) {
ret = -errno;
printk("run_helper : clone failed, errno = %d\n", errno);
Expand All @@ -101,7 +101,7 @@ int run_helper(void (*pre_exec)(void *), void *pre_data, char **argv)
ret = n;
kill(pid, SIGKILL);
}
CATCH_EINTR(waitpid(pid, NULL, 0));
CATCH_EINTR(waitpid(pid, NULL, __WCLONE));
}

out_free2:
Expand All @@ -126,15 +126,15 @@ int run_helper_thread(int (*proc)(void *), void *arg, unsigned int flags,
return -ENOMEM;

sp = stack + UM_KERN_PAGE_SIZE - sizeof(void *);
pid = clone(proc, (void *) sp, flags | SIGCHLD, arg);
pid = clone(proc, (void *) sp, flags, arg);
if (pid < 0) {
err = -errno;
printk("run_helper_thread : clone failed, errno = %d\n",
errno);
return err;
}
if (stack_out == NULL) {
CATCH_EINTR(pid = waitpid(pid, &status, 0));
CATCH_EINTR(pid = waitpid(pid, &status, __WCLONE));
if (pid < 0) {
err = -errno;
printk("run_helper_thread - wait failed, errno = %d\n",
Expand All @@ -150,14 +150,30 @@ int run_helper_thread(int (*proc)(void *), void *arg, unsigned int flags,
return pid;
}

int helper_wait(int pid)
int helper_wait(int pid, int nohang, char *pname)
{
int ret;
int ret, status;
int wflags = __WCLONE;

CATCH_EINTR(ret = waitpid(pid, NULL, WNOHANG));
if (nohang)
wflags |= WNOHANG;

if (!pname)
pname = "helper_wait";

CATCH_EINTR(ret = waitpid(pid, &status, wflags));
if (ret < 0) {
ret = -errno;
printk("helper_wait : waitpid failed, errno = %d\n", errno);
}
return ret;
printk(UM_KERN_ERR "%s : waitpid process %d failed, "
"errno = %d\n", pname, pid, errno);
return -errno;
} else if (nohang && ret == 0) {
printk(UM_KERN_ERR "%s : process %d has not exited\n",
pname, pid);
return -ECHILD;
} else if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) {
printk(UM_KERN_ERR "%s : process %d didn't exit with "
"status 0\n", pname, pid);
return -ECHILD;
} else
return 0;
}
4 changes: 2 additions & 2 deletions trunk/arch/um/os-Linux/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ void os_kill_process(int pid, int reap_child)
{
kill(pid, SIGKILL);
if (reap_child)
CATCH_EINTR(waitpid(pid, NULL, 0));
CATCH_EINTR(waitpid(pid, NULL, __WALL));
}

/* This is here uniquely to have access to the userspace errno, i.e. the one
Expand Down Expand Up @@ -130,7 +130,7 @@ void os_kill_ptraced_process(int pid, int reap_child)
ptrace(PTRACE_KILL, pid);
ptrace(PTRACE_CONT, pid);
if (reap_child)
CATCH_EINTR(waitpid(pid, NULL, 0));
CATCH_EINTR(waitpid(pid, NULL, __WALL));
}

/* Don't use the glibc version, which caches the result in TLS. It misses some
Expand Down
12 changes: 7 additions & 5 deletions trunk/arch/um/os-Linux/skas/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void wait_stub_done(int pid)
int n, status, err;

while (1) {
CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED));
CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED | __WALL));
if ((n < 0) || !WIFSTOPPED(status))
goto bad_wait;

Expand Down Expand Up @@ -153,7 +153,7 @@ static void handle_trap(int pid, struct uml_pt_regs *regs,
panic("handle_trap - continuing to end of syscall "
"failed, errno = %d\n", errno);

CATCH_EINTR(err = waitpid(pid, &status, WUNTRACED));
CATCH_EINTR(err = waitpid(pid, &status, WUNTRACED | __WALL));
if ((err < 0) || !WIFSTOPPED(status) ||
(WSTOPSIG(status) != SIGTRAP + 0x80)) {
err = ptrace_dump_regs(pid);
Expand Down Expand Up @@ -255,16 +255,18 @@ int start_userspace(unsigned long stub_stack)
panic("start_userspace : mmap failed, errno = %d", errno);
sp = (unsigned long) stack + UM_KERN_PAGE_SIZE - sizeof(void *);

flags = CLONE_FILES | SIGCHLD;
flags = CLONE_FILES;
if (proc_mm)
flags |= CLONE_VM;
else
flags |= SIGCHLD;

pid = clone(userspace_tramp, (void *) sp, flags, (void *) stub_stack);
if (pid < 0)
panic("start_userspace : clone failed, errno = %d", errno);

do {
CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED));
CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED | __WALL));
if (n < 0)
panic("start_userspace : wait failed, errno = %d",
errno);
Expand Down Expand Up @@ -314,7 +316,7 @@ void userspace(struct uml_pt_regs *regs)
"pid=%d, ptrace operation = %d, errno = %d\n",
pid, op, errno);

CATCH_EINTR(err = waitpid(pid, &status, WUNTRACED));
CATCH_EINTR(err = waitpid(pid, &status, WUNTRACED | __WALL));
if (err < 0)
panic("userspace - waitpid failed, errno = %d\n",
errno);
Expand Down
2 changes: 1 addition & 1 deletion trunk/arch/um/os-Linux/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ void os_dump_core(void)
* nothing reasonable to do if that fails.
*/

while ((pid = waitpid(-1, NULL, WNOHANG)) > 0)
while ((pid = waitpid(-1, NULL, WNOHANG | __WALL)) > 0)
os_kill_ptraced_process(pid, 0);

abort();
Expand Down

0 comments on commit 944fadb

Please sign in to comment.