20void record(
char *buf,
int len,
char *direction)
28 i = byte_chr(buf,len,
'\n');
54void doit(
int fdleft,
int fdright)
73 io0->events = IOPAUSE_READ;
79 ioleft->events = IOPAUSE_WRITE;
85 ioright->fd = fdright;
86 ioright->events = IOPAUSE_READ;
92 io1->events = IOPAUSE_WRITE;
96 taia_uint(&deadline,3600);
97 taia_add(&deadline,&stamp,&deadline);
98 riop = iopause(x,xlen,&deadline,&stamp);
100 if (riop > 0 && io0 && io0->revents) {
106 buffer_puts(&
ssrecord,
" < [EOF]\n");
115 if (ioleft && ioleft->revents) {
122 if (ioright && ioright->revents) {
126 buffer_puts(&
ssrecord,
" > [EOF]\n");
134 if (io1 && io1->revents) {
145int main(
int argc,
char *
const *argv,
char *
const *envp)
150 pid[fmt_ulong(
pid,getpid())] = 0;
153 logmsg(
WHO,100,USAGE,
"program [ arg ... ]");
156 if (
pipe(piin) == -1)
157 logmsg(
WHO,111,FATAL,
"unable to create pipe");
158 if (
pipe(piout) == -1)
159 logmsg(
WHO,111,FATAL,
"unable to create pipe");
163 logmsg(
WHO,111,FATAL,
"unable to fork");
165 sig_ignore(sig_pipe);
168 doit(piin[1],piout[0]);
173 if (fd_move(0,piin[0]) == -1)
174 logmsg(
WHO,111,FATAL,
"unable to move descriptors");
175 if (fd_move(1,piout[1]) == -1)
176 logmsg(
WHO,111,FATAL,
"unable to move descriptors");
178 pathexec_run(argv[1],argv + 1,envp);
179 logmsg(
WHO,111,FATAL,B(
"unable to run: ",argv[1]));
void record(char *buf, int len, char *direction)
void doit(int fdleft, int fdright)
int read(int, char *, int)
int write(int, char *, int)