1 --- system.c.orig 2003-05-20 15:23:25.000000000 -0700
2 +++ system.c 2006-06-24 18:48:47.000000000 -0700
4 #include "un-namespace.h"
5 #include "libc_private.h"
10 +static pthread_mutex_t __systemfn_mutex = PTHREAD_MUTEX_INITIALIZER;
11 +extern int __unix_conforming;
12 +#ifdef VARIANT_CANCELABLE
13 +extern void _pthread_testcancel(pthread_t thread, int isconforming);
14 +#endif /* VARIANT_CANCELABLE */
15 +#endif /* __DARWIN_UNIX03 */
21 struct sigaction ign, intact, quitact;
22 sigset_t newsigblock, oldsigblock;
24 - if (!command) /* just checking... */
27 + if (__unix_conforming == 0)
28 + __unix_conforming = 1;
29 +#ifdef VARIANT_CANCELABLE
30 + _pthread_testcancel(pthread_self(), 1);
31 +#endif /* VARIANT_CANCELABLE */
32 +#endif /* __DARWIN_UNIX03 */
34 + if (!command) { /* just checking... */
35 + if (access(_PATH_BSHELL, F_OK) == -1) /* if no sh or no access */
42 + pthread_mutex_lock(&__systemfn_mutex);
43 +#endif /* __DARWIN_UNIX03 */
45 * Ignore SIGINT and SIGQUIT, block SIGCHLD. Remember to save
46 * existing signal dispositions.
48 (void)_sigaction(SIGINT, &intact, NULL);
49 (void)_sigaction(SIGQUIT, &quitact, NULL);
50 (void)_sigprocmask(SIG_SETMASK, &oldsigblock, NULL);
52 + pthread_mutex_unlock(&__systemfn_mutex);
53 +#endif /* __DARWIN_UNIX03 */
54 execl(_PATH_BSHELL, "sh", "-c", command, (char *)NULL);
58 (void)_sigaction(SIGINT, &intact, NULL);
59 (void)_sigaction(SIGQUIT, &quitact, NULL);
60 (void)_sigprocmask(SIG_SETMASK, &oldsigblock, NULL);
62 + pthread_mutex_unlock(&__systemfn_mutex);
63 +#endif /* __DARWIN_UNIX03 */
64 return(pid == -1 ? -1 : pstat);