home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume38 / menushell / part03 / xsystem.c < prev   
Encoding:
C/C++ Source or Header  |  1993-07-30  |  578 b   |  30 lines

  1. /*
  2.  * Pilfered from berkeley code.
  3.  */
  4. #if defined(LIBC_SCCS) && !defined(lint)
  5. static char sccsid[] = "@(#)system.c    5.2 (Berkeley) 3/9/86";
  6. #endif LIBC_SCCS and not lint
  7.  
  8. #include    <signal.h>
  9.  
  10. system(s)
  11. char *s;
  12. {
  13.     int status, pid, w;
  14.     register int (*istat)(), (*qstat)();
  15.  
  16.     if ((pid = vfork()) == 0) {
  17.         execl("/bin/csh", "csh", "-fc", s, 0);
  18.         _exit(127);
  19.     }
  20.     istat = signal(SIGINT, SIG_IGN);
  21.     qstat = signal(SIGQUIT, SIG_IGN);
  22.     while ((w = wait(&status)) != pid && w != -1)
  23.         ;
  24.     if (w == -1)
  25.         status = -1;
  26.     signal(SIGINT, istat);
  27.     signal(SIGQUIT, qstat);
  28.     return(status);
  29. }
  30.