10 static void install(int);
20 for (i = 0; i < cormap->nsegs; i++)
21 if (cormap->seg[i].inuse && cormap->seg[i].fd >= 0)
22 close(cormap->seg[i].fd);
37 snprint(buf, sizeof(buf), "/proc/%d/mem", pid);
38 fcor = open(buf, ORDWR);
40 error("setproc: open %s: %r", buf);
42 checkqid(symmap->seg[0].fd, pid);
48 cormap = attachproc(pid, kernel, fcor, &fhdr);
50 error("setproc: can't make coremap: %r");
51 i = findseg(cormap, "text");
53 cormap->seg[i].name = "*text";
54 i = findseg(cormap, "data");
56 cormap->seg[i].name = "*data";
69 error("new: fork %r");
71 rfork(RFNAMEG|RFNOTEG);
73 snprint(buf, sizeof(buf), "/proc/%d/ctl", getpid());
74 fd = open(buf, ORDWR);
76 fatal("new: open %s: %r", buf);
83 for(i = 3; i < NFD; i++)
86 open("/dev/cons", OREAD);
87 open("/dev/cons", OWRITE);
88 open("/dev/cons", OWRITE);
90 fatal("new: exec %s: %r", argv[0]);
117 snprint(buf, sizeof(buf), "/proc/%d/note", pid);
118 fd = open(buf, OREAD);
120 error("pid=%d: open note: %r", pid);
127 i = read(fd, buf, sizeof(buf));
132 l->string = strnode(buf);
148 np = an(ONAME, ZN, ZN);
154 np = an(OCALL, np, p);
168 for(i = 0; i < Maxproc; i++) {
172 if(p == 0 && new == -1)
176 error("no free process slots");
178 snprint(buf, sizeof(buf), "/proc/%d/ctl", pid);
179 fd = open(buf, OWRITE);
181 error("pid=%d: open ctl: %r", pid);
185 s = look("proclist");
193 callhook("procattach");
203 for(i = 0; i < Maxproc; i++) {
204 if(ptab[i].pid == pid) {
207 s = look("proclist");
209 for(f = *d; f; f = f->next) {
216 if(s->v->ival == pid)
224 msg(int pid, char *msg)
230 for(i = 0; i < Maxproc; i++) {
231 if(ptab[i].pid == pid) {
233 if(write(ptab[i].ctl, msg, l) != l) {
234 errstr(err, sizeof err);
235 if(strcmp(err, "process exited") == 0)
237 error("msg: pid=%d %s: %s", pid, msg, err);
242 error("msg: pid=%d: not found for %s", pid, msg);
249 char *argv[16], buf[64];
250 static char status[128];
252 snprint(buf, sizeof(buf), "/proc/%d/status", pid);
253 fd = open(buf, OREAD);
255 error("open %s: %r", buf);
257 n = read(fd, status, sizeof(status)-1);
260 error("read %s: %r", buf);
263 if(tokenize(status, argv, nelem(argv)-1) < 3)
264 error("tokenize %s: %r", buf);
275 if((w = wait()) == nil)