3.8.52 system1.c

We use cookies. Read the Privacy and Cookie Policy

3.8.52 system1.c

#include <signal.h>

system(s) /* run command line s */

 char *s;

{

 int status, pid, w, tty;

 int (*istat)(), (*qstat)();

 ...

 if ((pid = fork()) == 0) {

  ...

  execlp("sh", "sh", "-c", s, (char*)0);

  exit(127);

 }

 ...

 istat = signal(SIGINT, SIG_IGN);

 qstat = signal(SIGQUIT, SIG_IGN);

 while ((w = wait(&status)) != pid && w != -1)

  ;

 if (w == -1)

  status = -1;

 signal(SIGINT, istat);

 signal(SIGQUIT, qstat);

 return status;

}

Данный текст является ознакомительным фрагментом.