This patch corrects a couple of minor problems with telnet when using the notkbd option (-n). The first issue was to disable changing raw mode when a pipe was being used. This would result in raw mode being enabled on the calling console. The second issue was a deadlock caused by the net child being handed a terminal note. This would cause the parent to spin waiting for the child to notify. This was changed to a waitpid loop such that the main thread can shutdown gracefully if needed. Reference: /n/sources/patch/maybe/telnet-notkbd Date: Thu Dec 5 06:09:07 CET 2013 Signed-off-by: sstallion@gmail.com --- /sys/src/cmd/ip/telnet.c Thu Dec 5 06:09:02 2013 +++ /sys/src/cmd/ip/telnet.c Thu Dec 5 06:09:00 2013 @@ -159,12 +159,13 @@ netpid = pid; notify(notifyf); fromkbd(net); - if(notkbd) - for(;;) - sleep(1000); // sleep(0) is a cpuhog + if(notkbd){ + while(waitpid() != -1) + ; + }else + sendnote(netpid, "die"); if (svc) remove(svc); - sendnote(netpid, "die"); exits(0); } } @@ -323,6 +324,8 @@ void rawon(void) { + if(notkbd) + return; if(debug) fprint(2, "rawon\n"); if(consctl < 0) @@ -340,6 +343,8 @@ void rawoff(void) { + if(notkbd) + return; if(debug) fprint(2, "rawoff\n"); if(consctl < 0)