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 <u.h>
#include <libc.h>
#include <stdio.h>

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

Reply via email to