if (data->pre_exec != NULL)
(*data->pre_exec)(data->pre_data);
err = execvp_noalloc(data->buf, argv[0], argv);
/* If the exec succeeds, we don't get here */
CATCH_EINTR(ret = write(data->fd, &err, sizeof(err)));
return 0;
}
/* Returns either the pid of the child process we run or -E* on failure. */ int run_helper(void (*pre_exec)(void *), void *pre_data, char **argv)
{ struct helper_data data; unsignedlong stack, sp; int pid, fds[2], ret, n;
stack = alloc_stack(0, __uml_cant_sleep()); if (stack == 0) return -ENOMEM;
ret = socketpair(AF_UNIX, SOCK_STREAM, 0, fds); if (ret < 0) {
ret = -errno;
printk(UM_KERN_ERR "run_helper : pipe failed, errno = %d\n",
errno); goto out_free;
}
/* * Read the errno value from the child, if the exec failed, or get 0 if * the exec succeeded because the pipe fd was set as close-on-exec.
*/
n = read(fds[0], &ret, sizeof(ret)); if (n == 0) {
ret = pid;
} else { if (n < 0) {
n = -errno;
printk(UM_KERN_ERR "run_helper : read on pipe failed, " "ret = %d\n", -n);
ret = n;
}
CATCH_EINTR(waitpid(pid, NULL, __WALL));
}
if (ret < 0)
printk(UM_KERN_ERR "run_helper : failed to exec %s on host: %s\n",
argv[0], strerror(-ret));
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.