- /* See notes in system.c for why this is needed. */
- for (i=1; i<=8*__SYSCALL_SSLEN; i++) {
- struct sigaction sa;
- __libc_sigaction(i, 0, &sa);
- if (sa.sa_handler!=SIG_IGN && sa.sa_handler!=SIG_DFL) {
- sa.sa_handler = SIG_DFL;
- __libc_sigaction(i, &sa, 0);
+ e = ENOMEM;
+ if (!posix_spawn_file_actions_init(&fa)) {
+ if (!posix_spawn_file_actions_adddup2(&fa, p[1-op], 1-op)) {
+ if (!(e = posix_spawn(&pid, "/bin/sh", &fa, 0,
+ (char *[]){ "sh", "-c", (char *)cmd, 0 }, __environ))) {
+ posix_spawn_file_actions_destroy(&fa);
+ f->pipe_pid = pid;
+ if (!strchr(mode, 'e'))
+ fcntl(p[op], F_SETFD, 0);
+ __syscall(SYS_close, p[1-op]);
+ FUNLOCK(f);
+ return f;
+ }