17 int xread(int fd
, char *buf
, int len
)
21 int ret
= read(fd
, buf
+ nr
, len
- nr
);
22 if (ret
== -1 && (errno
== EAGAIN
|| errno
== EINTR
))
31 int xwrite(int fd
, char *buf
, int len
)
35 int ret
= write(fd
, buf
+ nw
, len
- nw
);
36 if (ret
== -1 && (errno
== EAGAIN
|| errno
== EINTR
))
45 void exec_file(char *filename
, char **args
)
48 if (!(pid
= fork())) {
49 execvp(filename
, args
);
52 waitpid(pid
, NULL
, 0);
55 void exec_pipe(char *file
, char **argv
, char *s
, int len
)
60 if (!(pid
= fork())) {
62 dup2(fds
[0], STDIN_FILENO
);
67 write(fds
[1], s
, len
);
69 waitpid(pid
, NULL
, 0);