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);
36 sigaddset(&new, SIGCHLD);
37 sigprocmask(SIG_BLOCK, &new, 0);
38 while (waitpid(pid, &status, 0) && errno == EINTR);
42 sigaction(SIGINT, &oldint, NULL);
43 sigaction(SIGQUIT, &oldquit, NULL);
44 sigprocmask(SIG_SETMASK, &old, NULL);
48 /* Before we can unblock signals in the child, all signal
49 * handlers must be eliminated -- even implementation-internal
50 * ones. Otherwise, a signal handler could run in the child
51 * and clobber the parent's memory (due to vfork). */
52 for (i=1; i<=8*__SYSCALL_SSLEN; i++) {
54 __libc_sigaction(i, 0, &sa);
55 if (sa.sa_handler!=SIG_IGN && sa.sa_handler!=SIG_DFL) {
56 sa.sa_handler = SIG_DFL;
57 __libc_sigaction(i, &sa, 0);
61 sigprocmask(SIG_SETMASK, &old, NULL);
62 execl("/bin/sh", "sh", "-c", cmd, (char *)0);