4 #include "threadimpl.h"
12 iointerrupt(Ioproc *io)
16 write(io->ctl, "interrupt", 9);
28 if(io = mallocz(sizeof(*io), 1)){
31 snprint(buf, sizeof(buf), "/proc/%d/ctl", getpid());
32 if((io->ctl = open(buf, OWRITE)) < 0){
36 if((io->creply = chancreate(sizeof(void*), 0)) == nil){
44 while(send(c, &io) < 0)
50 while(recv(io->c, &r) < 0)
56 strcpy(r->err, "interrupted");
57 } else if((r->ret = r->op(&r->arg)) < 0)
58 rerrstr(r->err, sizeof r->err);
62 write(io->ctl, "nointerrupt", 11);
64 while(send(io->creply, &r) < 0)
81 if((c = chancreate(sizeof(void*), 0)) == nil)
82 sysfatal("ioproc chancreate");
83 proccreate(xioproc, c, STACK);
84 while(recv(c, &io) < 0)
87 sysfatal("ioproc alloc");
92 closeioproc(Ioproc *io)
97 while(sendp(io->c, nil) < 0)