diff options
author | Eric Andersen <andersen@codepoet.org> | 2000-10-09 20:06:30 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2000-10-09 20:06:30 +0000 |
commit | c1fe19d4c1db610692365472a90f4661e48449c1 (patch) | |
tree | d0b0219ffca3c4c4256f55c4aea4513e43d6aecd /libc/stdlib/system.c | |
parent | 9efafb8bbc7408b04643dcd53825d971577b4d9d (diff) |
Bug ugly formatting update
Diffstat (limited to 'libc/stdlib/system.c')
-rw-r--r-- | libc/stdlib/system.c | 80 |
1 files changed, 39 insertions, 41 deletions
diff --git a/libc/stdlib/system.c b/libc/stdlib/system.c index 6c8a42dee..061dbc914 100644 --- a/libc/stdlib/system.c +++ b/libc/stdlib/system.c @@ -4,46 +4,44 @@ #include <unistd.h> #include <sys/wait.h> -int -system(command) -char * command; +int system(command) +char *command; { - int wait_val, pid; - __sighandler_t save_quit, save_int, save_chld; - - if( command == 0 ) return 1; - - save_quit = signal(SIGQUIT, SIG_IGN); - save_int = signal(SIGINT, SIG_IGN); - save_chld = signal(SIGCHLD, SIG_DFL); - - if( (pid=vfork()) < 0 ) - { - signal(SIGQUIT, save_quit); - signal(SIGINT, save_int); - signal(SIGCHLD, save_chld); - return -1; - } - if( pid == 0 ) - { - signal(SIGQUIT, SIG_DFL); - signal(SIGINT, SIG_DFL); - signal(SIGCHLD, SIG_DFL); - - execl("/bin/sh", "sh", "-c", command, (char*)0); - _exit(127); - } - /* Signals are not absolutly guarenteed with vfork */ - signal(SIGQUIT, SIG_IGN); - signal(SIGINT, SIG_IGN); - - printf("Waiting for child %d\n", pid); - - if (wait4(pid, &wait_val, 0, 0) == -1) - wait_val = -1; - - signal(SIGQUIT, save_quit); - signal(SIGINT, save_int); - signal(SIGCHLD, save_chld); - return wait_val; + int wait_val, pid; + __sighandler_t save_quit, save_int, save_chld; + + if (command == 0) + return 1; + + save_quit = signal(SIGQUIT, SIG_IGN); + save_int = signal(SIGINT, SIG_IGN); + save_chld = signal(SIGCHLD, SIG_DFL); + + if ((pid = vfork()) < 0) { + signal(SIGQUIT, save_quit); + signal(SIGINT, save_int); + signal(SIGCHLD, save_chld); + return -1; + } + if (pid == 0) { + signal(SIGQUIT, SIG_DFL); + signal(SIGINT, SIG_DFL); + signal(SIGCHLD, SIG_DFL); + + execl("/bin/sh", "sh", "-c", command, (char *) 0); + _exit(127); + } + /* Signals are not absolutly guarenteed with vfork */ + signal(SIGQUIT, SIG_IGN); + signal(SIGINT, SIG_IGN); + + printf("Waiting for child %d\n", pid); + + if (wait4(pid, &wait_val, 0, 0) == -1) + wait_val = -1; + + signal(SIGQUIT, save_quit); + signal(SIGINT, save_int); + signal(SIGCHLD, save_chld); + return wait_val; } |