21 int open_read(const char *fname
) {
22 return open(fname
, O_RDONLY
);
25 int open_write(const char *fname
) {
26 return open(fname
, O_WRONLY
| O_TRUNC
| O_CREAT
,
27 S_IWUSR
| S_IRUSR
| S_IROTH
| S_IRGRP
);
40 /* This waits and then returns the exit status of the process that was
42 int smart_wait(int pid
) {
47 rc
= waitpid(pid
, &stat
, 0);
48 } while(rc
< 0 && errno
== EINTR
);
53 } else if (WIFEXITED(stat
)) {
54 return WEXITSTATUS(stat
);
55 } else if (WIFSIGNALED(stat
)) {
56 /* Fixme: psignal isn't portable (not in POSIX). */
57 psignal(WTERMSIG(stat
), "Error in subprocess");
58 return - WTERMSIG(stat
);
69 int execvp_no_vtalarm(const char *file
, char *const argv
[]) {
70 /* Reset the itimers in the child, so it doesn't get plagued
71 * by SIGVTALRM interrupts.
73 struct timeval tv_null
= { 0, 0 };
75 itv
.it_interval
= tv_null
;
76 itv
.it_value
= tv_null
;
77 setitimer(ITIMER_REAL
, &itv
, NULL
);
78 setitimer(ITIMER_VIRTUAL
, &itv
, NULL
);
79 setitimer(ITIMER_PROF
, &itv
, NULL
);
81 perror("Error in execvp");
85 #include <sys/types.h>