From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Nils M Holm" Date: Sat, 27 Jun 2015 22:30:11 +0200 To: Fans of the Plan 9 OS <9fans@9fans.net> Message-ID: <20150627203011.GB2121@ananda.local> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Subject: [9fans] Help with interrupting fgetc() Topicbox-Message-UUID: 5c413c6c-ead9-11e9-9d60-3106f5b1d025 I'm trying to get the DEL key to cause an error in an interpreter I'm writing. On Unix, I just catch SIGINT and set an error flag that causes the interpreter to return to the REPL. On Plan9, fgetc() seems to return EOF after catching an "interrupted" note. To make a long story short, I expected the following code to echo characters typed and print "oopsie" when DEL is pressed. It should keep echoing after printing "oopsie", but it just exits instead. What am I missing? - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #include #include #include void n(void *x, char *s) { if (!strcmp(s, "interrupt")) { print("oopsie!\n"); noted(NCONT); } else { noted(NDFLT); } } main() { int c; notify(n); c = fgetc(stdin); while (c != EOF) { fputc(c, stdout); c = fgetc(stdin); } return 0; } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- Nils M Holm < n m h @ t 3 x . o r g > www.t3x.org