exit gracefully on echo exit>/proc/pid/ctl remove old code Notes: Tue Mar 14 08:14:45 EST 2006 rsc I put the cleanups in, but I left the exit behavior as it is. It's true that the bind wasn't doing anything, but that might be for the best -- it seems antisocial to me to reconstruct /proc. Exiting will deaden the mount anyway, leaving whatever was there before. Also, sending nil to rchan may not work, especially if the remote machine is acting up. I'm more comfortable with postnote. Reference: /n/sources/patch/applied/rdbfs-exit Date: Mon Mar 13 23:46:49 CET 2006 Reviewed-by: rsc --- /sys/src/cmd/rdbfs.c Mon Mar 13 23:45:04 2006 +++ /sys/src/cmd/rdbfs.c Mon Mar 13 23:44:59 2006 @@ -132,16 +132,12 @@ }; int textfd; -int srvfd; int rfd; Biobuf rfb; char* portname = "/dev/eia0"; char* textfile = "/386/9pc"; char* procname = "1"; Channel* rchan; -char* Eexist = "file does not exist"; - -char* progname = "rdbfs"; void usage(void) @@ -150,22 +146,6 @@ exits("usage"); } -int -forkproc(void (*fn)(void)) -{ - int pid; - switch(pid=rfork(RFNAMEG|RFMEM|RFPROC)){ - case -1: - sysfatal("fork: %r"); - case 0: - fn(); - _exits(0); - default: - return pid; - } - return -1; /* not reached */ -} - void noalarm(void*, char *msg) { @@ -248,6 +228,7 @@ } Break2:; } + bind("#p", "/proc", MREPL); } void @@ -341,9 +322,7 @@ if(strncmp(r->ifcall.data, "kill", 4) == 0 || strncmp(r->ifcall.data, "exit", 4) == 0) { respond(r, nil); - bind("#p", "/proc", MREPL); - postnote(PNGROUP, getpid(), "umount"); - exits(nil); + sendp(rchan, 0); }else if(strncmp(r->ifcall.data, "refresh", 7) == 0){ flushcache(); respond(r, nil); @@ -388,17 +367,10 @@ "status", Xstatus, 0444, }; -void -killall(Srv*) -{ - postnote(PNGROUP, getpid(), "kill"); -} - Srv fs = { .open= fsopen, .read= fsread, .write= fswrite, -.end= killall, }; void @@ -441,7 +413,6 @@ sysfatal("pipe: %r"); fmtinstall('F', fcallfmt); - srvfd = p[1]; proccreate(eiaread, nil, 8192); fs.tree = alloctree("rdbfs", "rdbfs", DMDIR|0555, nil);