int execvp(const char *file, char *const *argv) { sigset_t saved; int rc = -1; if (!pseudo_check_wrappers() || !real_execvp) { /* rc was initialized to the "failure" value */ pseudo_enosys("execvp"); return rc; } pseudo_debug(4, "called: execvp\n"); pseudo_sigblock(&saved); if (pseudo_getlock()) { errno = EBUSY; sigprocmask(SIG_SETMASK, &saved, NULL); return -1; } int save_errno; /* exec*() use this to restore the sig mask */ pseudo_saved_sigmask = saved; rc = wrap_execvp(file, argv); save_errno = errno; pseudo_droplock(); sigprocmask(SIG_SETMASK, &saved, NULL); pseudo_debug(4, "completed: execvp\n"); errno = save_errno; return rc; }
int fork(void) { sigset_t saved; int rc = -1; if (!pseudo_check_wrappers() || !real_fork) { /* rc was initialized to the "failure" value */ pseudo_enosys("fork"); return rc; } pseudo_debug(4, "called: fork\n"); pseudo_sigblock(&saved); if (pseudo_getlock()) { errno = EBUSY; sigprocmask(SIG_SETMASK, &saved, NULL); return -1; } int save_errno; rc = wrap_fork(); save_errno = errno; pseudo_droplock(); sigprocmask(SIG_SETMASK, &saved, NULL); pseudo_debug(4, "completed: fork\n"); errno = save_errno; return rc; }
int clone(int (*fn)(void *), void *child_stack, int flags, void *arg, ...) { sigset_t saved; va_list ap; pid_t *pid; struct user_desc *tls; pid_t *ctid; int rc = -1; if (!pseudo_check_wrappers() || !real_clone) { /* rc was initialized to the "failure" value */ pseudo_enosys("clone"); return rc; } va_start(ap, arg); pid = va_arg(ap, pid_t *); tls = va_arg(ap, struct user_desc *); ctid = va_arg(ap, pid_t *); va_end(ap); pseudo_debug(PDBGF_WRAPPER, "called: clone\n"); pseudo_sigblock(&saved); if (pseudo_getlock()) { errno = EBUSY; sigprocmask(SIG_SETMASK, &saved, NULL); return -1; } int save_errno; int save_disabled = pseudo_disabled; #include "guts/clone.c" if (save_disabled != pseudo_disabled) { if (pseudo_disabled) { pseudo_disabled = 0; pseudo_magic(); } else { pseudo_disabled = 1; pseudo_antimagic(); } } save_errno = errno; pseudo_droplock(); sigprocmask(SIG_SETMASK, &saved, NULL); pseudo_debug(PDBGF_WRAPPER, "completed: clone\n"); errno = save_errno; return rc; }
int execle(const char *file, const char *arg, ...) { sigset_t saved; va_list ap; char **argv; char **envp; int rc = -1; if (!pseudo_check_wrappers()) { /* rc was initialized to the "failure" value */ pseudo_enosys("execle"); return rc; } va_start(ap, arg); argv = execl_to_v(ap, arg, (char *const **)&envp); va_end(ap); if (!argv) { errno = ENOMEM; return -1; } pseudo_debug(4, "called: execle\n"); pseudo_sigblock(&saved); if (pseudo_getlock()) { errno = EBUSY; sigprocmask(SIG_SETMASK, &saved, NULL); return -1; } int save_errno; /* exec*() use this to restore the sig mask */ pseudo_saved_sigmask = saved; rc = wrap_execve(file, argv, envp); save_errno = errno; pseudo_droplock(); sigprocmask(SIG_SETMASK, &saved, NULL); pseudo_debug(4, "completed: execle\n"); errno = save_errno; free(argv); return rc; }