From: erik quanstrom <quanstro@quanstro.net>
To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>
Subject: Re: [9fans] Help with interrupting fgetc()
Date: Sat, 27 Jun 2015 18:29:12 -0700 [thread overview]
Message-ID: <91e91b3f-1cae-44d6-8cfe-271392143ce1@email.android.com> (raw)
In-Reply-To: <20150627203011.GB2121@ananda.local>
two additional points. I the style for note matching is strstr matching because the exact string can't be counted on. for example details may be added. also the bio(2) library and peint(2) areusually used instead of stdio.
- erik
On Jun 27, 2015 1:30 PM, Nils M Holm <nmh@t3x.org> wrote:
>
>
> 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
>
>
next prev parent reply other threads:[~2015-06-28 1:29 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-27 20:30 Nils M Holm
2015-06-27 20:58 ` Charles Forsyth
2015-06-27 21:19 ` Nils M Holm
2015-06-27 21:12 ` Charles Forsyth
2015-06-27 21:21 ` Nils M Holm
2015-06-28 1:29 ` erik quanstrom [this message]
2015-06-28 7:29 ` Nils M Holm
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=91e91b3f-1cae-44d6-8cfe-271392143ce1@email.android.com \
--to=quanstro@quanstro.net \
--cc=9fans@9fans.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).