2 * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
4 * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
13 libc_hidden_proto(_exit)
14 libc_hidden_proto(wait4)
15 libc_hidden_proto(execl)
16 libc_hidden_proto(signal)
17 libc_hidden_proto(vfork)
19 /* uClinux-2.0 has vfork, but Linux 2.0 doesn't */
20 #include <sys/syscall.h>
21 #if ! defined __NR_vfork
23 libc_hidden_proto(fork)
26 int __libc_system(char *command)
29 __sighandler_t save_quit, save_int, save_chld;
34 save_quit = signal(SIGQUIT, SIG_IGN);
35 save_int = signal(SIGINT, SIG_IGN);
36 save_chld = signal(SIGCHLD, SIG_DFL);
38 if ((pid = vfork()) < 0) {
39 signal(SIGQUIT, save_quit);
40 signal(SIGINT, save_int);
41 signal(SIGCHLD, save_chld);
45 signal(SIGQUIT, SIG_DFL);
46 signal(SIGINT, SIG_DFL);
47 signal(SIGCHLD, SIG_DFL);
49 execl("/bin/sh", "sh", "-c", command, (char *) 0);
52 /* Signals are not absolutly guarenteed with vfork */
53 signal(SIGQUIT, SIG_IGN);
54 signal(SIGINT, SIG_IGN);
57 __printf("Waiting for child %d\n", pid);
60 if (wait4(pid, &wait_val, 0, 0) == -1)
63 signal(SIGQUIT, save_quit);
64 signal(SIGINT, save_int);
65 signal(SIGCHLD, save_chld);
68 weak_alias(__libc_system,system)