Книга: UNIX — универсальная среда программирования
3.8.53 system.c
3.8.53 system.c
/*
* Safer version of system for interactive programs
*/
#include <signal.h>
#include <stdio.h>
system(s) /* run command line s */
char *s;
{
int status, pid, w, tty;
int (*istat)(), (*qstat)();
extern char *progname;
fflush(stdout);
tty = open("/dev/tty", 2);
if (tty == -1) {
fprintf (stderr, "%s: can't open /dev/ttyn", progname);
return -1;
}
if ((pid = fork()) == 0) {
close(0);
dup(tty);
close(1);
dup(tty);
close(2);
dup(tty);
close(tty);
execlp("sh", "sh", "-c", s, (char*)0);
exit(127);
}
close(tty);
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;
}
- 3.8.1 addup1
- 3.8.2. addup2
- 3.8.3 backup
- 3.8.4 backwards
- 3.8.5 badpick.c
- 3.8.6 bundle
- 3.8.7 cal
- 3.8.8 calendar1
- 3.8.9 calendar2
- 3.8.10 calendar3
- 3.8.11 cat0.c
- 3.8.12 checkmail.c
- 3.8.13 checkmail.sh
- 3.8.14 cp.c
- 3.8.15 doctype
- 3.8.16 double
- 3.8.17 efopen.c
- 3.8.18 error.c
- 3.8.19 field1
- 3.8.20 field2
- 3.8.21 fold
- 3.8.22 frequent
- 3.8.23 frequent2
- 3.8.24 get
- 3.8.25 get.с
- 3.8.26 getname
- 3.8.27 idiff.c
- 3.8.28 makefile
- 3.8.29 newer
- 3.8.30 news1
- 3.8.31 news2
- 3.8.32 news3
- 3.8.33 nohup
- 3.8.34 older
- 3.8.35 overwrite1
- 3.8.36 overwrite2
- 3.8.37 overwrite3
- 3.8.38 p1.c
- 3.8.39 p2.c
- 3.8.40 p3.c
- 3.8.41 p4.c
- 3.8.42 pick1
- 3.8.43 pick.c
- 3.8.44 prpages
- 3.8.45 put
- 3.8.46 readslow.c
- 3.8.47 replace
- 3.8.48 signaltest.c
- 3.8.49 spname.c
- 3.8.50 strindex.c
- 3.8.51 sv.c
- 3.8.52 system1.c
- 3.8.53 system.c
- 3.8.54 timeout.c
- 3.8.55 toolong
- 3.8.56 ttyin1.c
- 3.8.57 ttyin2.c
- 3.5.58 vis1.c
- 3.5.59 vis2.c
- 3.8.60 vis3.c
- 3.8.61 waitfile.c
- 3.8.62 watchfor
- 3.8.63 watchwho
- 3.8.64 which1
- 3.8.65 which1.H
- 3.8.66 which2
- 3.8.67 wordfreq
- 3.8.68 zap1
- 3.8.69 zap2
- 3.8.70 zap.c
- Shared Cache file
- 8.5.2 Typical Condition Variable Operations
- Безопасность внешних таблиц. Параметр EXTERNAL FILE DIRECTORY
- 4.4.4 The Dispatcher
- Open Source Insight and Discussion
- SERVER PRIORITY CLASS
- DEADLOCK TIMEOUT
- Introduction to Microprocessors and Microcontrollers
- System tools used for debugging
- Integrated Secure Communications System
- Когда включаю компьютер, при загрузке пишется Insert system disk and press enter. Что нужно делать?
- На всех дисках моего компьютера есть папка System Volume Information. Для чего она нужна?