6 #include "pthread_impl.h"
12 weak_alias(dummy_0, __acquire_ptc);
13 weak_alias(dummy_0, __release_ptc);
16 void __testcancel(void);
18 int system(const char *cmd)
22 struct sigaction sa = { .sa_handler = SIG_IGN }, oldint, oldquit;
29 sigaction(SIGINT, &sa, &oldint);
30 sigaction(SIGQUIT, &sa, &oldquit);
31 sigprocmask(SIG_BLOCK, SIGALL_SET, &old);
36 if (pid) __release_ptc();
40 sigaddset(&new, SIGCHLD);
41 sigprocmask(SIG_BLOCK, &new, 0);
42 while (waitpid(pid, &status, 0) && errno == EINTR);
46 sigaction(SIGINT, &oldint, NULL);
47 sigaction(SIGQUIT, &oldquit, NULL);
48 sigprocmask(SIG_SETMASK, &old, NULL);
52 /* Before we can unblock signals in the child, all signal
53 * handlers must be eliminated -- even implementation-internal
54 * ones. Otherwise, a signal handler could run in the child
55 * and clobber the parent's memory (due to vfork). */
56 for (i=1; i<=8*__SYSCALL_SSLEN; i++) {
58 __libc_sigaction(i, 0, &sa);
59 if (sa.sa_handler!=SIG_IGN && sa.sa_handler!=SIG_DFL) {
60 sa.sa_handler = SIG_DFL;
61 __libc_sigaction(i, &sa, 0);
65 sigprocmask(SIG_SETMASK, &old, NULL);
66 execl("/bin/sh", "sh", "-c", cmd, (char *)0);