6 #include "pthread_impl.h"
12 weak_alias(dummy_0, __acquire_ptc);
13 weak_alias(dummy_0, __release_ptc);
17 int system(const char *cmd)
21 struct sigaction sa = { .sa_handler = SIG_IGN }, oldint, oldquit;
26 sigaction(SIGINT, &sa, &oldint);
27 sigaction(SIGQUIT, &sa, &oldquit);
28 sigprocmask(SIG_BLOCK, SIGALL_SET, &old);
33 if (pid) __release_ptc();
37 sigaddset(&new, SIGCHLD);
38 sigprocmask(SIG_BLOCK, &new, 0);
39 while (waitpid(pid, &status, 0) && errno == EINTR);
43 sigaction(SIGINT, &oldint, NULL);
44 sigaction(SIGQUIT, &oldquit, NULL);
45 sigprocmask(SIG_SETMASK, &old, NULL);
49 /* Before we can unblock signals in the child, all signal
50 * handlers must be eliminated -- even implementation-internal
51 * ones. Otherwise, a signal handler could run in the child
52 * and clobber the parent's memory (due to vfork). */
53 for (i=1; i<=8*__SYSCALL_SSLEN; i++) {
55 __libc_sigaction(i, 0, &sa);
56 if (sa.sa_handler!=SIG_IGN && sa.sa_handler!=SIG_DFL) {
57 sa.sa_handler = SIG_DFL;
58 __libc_sigaction(i, &sa, 0);
62 sigprocmask(SIG_SETMASK, &old, NULL);
63 execl("/bin/sh", "sh", "-c", cmd, (char *)0);