home *** CD-ROM | disk | FTP | other *** search
/ minnie.tuhs.org / unixen.tar / unixen / PDP-11 / Trees / V7 / usr / src / libc / stdio / system.c < prev    next >
Encoding:
C/C++ Source or Header  |  1979-01-10  |  402 b   |  23 lines

  1. #include    <signal.h>
  2.  
  3. system(s)
  4. char *s;
  5. {
  6.     int status, pid, w;
  7.     register int (*istat)(), (*qstat)();
  8.  
  9.     if ((pid = fork()) == 0) {
  10.         execl("/bin/sh", "sh", "-c", s, 0);
  11.         _exit(127);
  12.     }
  13.     istat = signal(SIGINT, SIG_IGN);
  14.     qstat = signal(SIGQUIT, SIG_IGN);
  15.     while ((w = wait(&status)) != pid && w != -1)
  16.         ;
  17.     if (w == -1)
  18.         status = -1;
  19.     signal(SIGINT, istat);
  20.     signal(SIGQUIT, qstat);
  21.     return(status);
  22. }
  23.