9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: "Howard Trickey" <howard@research.bell-labs.com>
To: <9fans@cse.psu.edu>
Subject: Re: [9fans] APE question
Date: Fri, 12 Oct 2001 10:45:55 -0400	[thread overview]
Message-ID: <EPEOIODEGHAONLDKOGLHCEMLCAAA.howard@research.bell-labs.com> (raw)
In-Reply-To: <cej-1011012163354.A01374@cejchan.gli.cas.cz>

> under APE, the following part of code:

>       printf("\nQuit [q], confirm [y], or change [menu] settings: ");
>        /* read one char */
>        ch = getchar();

According to the C standard, "The standard input and output streams are
fully buffered if and only if the stream can be determined not to refer to
an interactive device."  It doesn't say whether to use line buffering or no
buffering in the interactive case.  I chose line buffering.  So the above
might have worked if you'd put a '\n' at the end of the printf string.  (But
only "might": the code to test whether a file is "interactive" ---
isatty --- is hacky in the extreme, and only works sometimes; with Plan 9's
namespace stuff, it is hard to get right.)

As well as the fflush solution given earlier, you could also put a call like

	setvbuf(stdout, _IONBF, BUFSIZ);

near the beginning of your program.  But the fflush solution is probably
better.



  parent reply	other threads:[~2001-10-12 14:45 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-10-12 14:33 pac
2001-10-12 14:34 ` Boyd Roberts
2001-10-12 14:40 ` Laura Creighton
2001-10-12 14:45 ` Howard Trickey [this message]
2001-10-12 14:58   ` Howard Trickey
2001-10-15  4:20     ` pac
2001-10-15  9:11 ` Douglas A. Gwyn
  -- strict thread matches above, loose matches on Subject: below --
2001-10-12 14:32 rog
2001-10-12 14:21 pac
2001-10-12 14:14 presotto

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=EPEOIODEGHAONLDKOGLHCEMLCAAA.howard@research.bell-labs.com \
    --to=howard@research.bell-labs.com \
    --cc=9fans@cse.psu.edu \
    /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).