public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Bug in Control-d handling?
@ 2022-06-19 19:08 Ken Brown
  2022-06-20  8:59 ` Takashi Yano
  0 siblings, 1 reply; 9+ messages in thread
From: Ken Brown @ 2022-06-19 19:08 UTC (permalink / raw)
  To: cygwin

Consider the following program, which reads from standard input a line at a time 
and then echoes the input back to the terminal:

$ cat cat_line.c
#include <stdio.h>

int main ()
{
   char buf[BUFSIZ];

   while (fgets (buf, BUFSIZ, stdin))
     fputs (buf, stdout);
}

Run the program, type one or more characters (without hitting Enter), and type 
Ctrl-d until the program exits.  What I expect is that nothing visible happens 
on the first Ctrl-d [but the input is sent to the internal stdin buffer], and 
that the input is echoed and the program exits after the second Ctrl-d [the 
program sees EOF].  This is what happens on Linux.  On Cygwin, however, the 
program keeps running after the second Ctrl-d and doesn't exit until Ctrl-d is 
pressed a third time.

I observed this problem because of a failing Emacs test, in which the program 
"rev" was not seeing EOF after being sent Ctrl-d; "rev" does something like the 
test case above, but using fgetws instead of fgets.

Ken

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2022-07-04  8:10 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-19 19:08 Bug in Control-d handling? Ken Brown
2022-06-20  8:59 ` Takashi Yano
2022-06-20 10:22   ` Takashi Yano
2022-06-20 13:24     ` Ken Brown
2022-06-20 13:53       ` Eliot Moss
2022-06-20 17:50         ` Ken Brown
2022-07-04  8:10       ` Corinna Vinschen
2022-06-20 17:12     ` Achim Gratz
2022-06-20 19:22     ` Brian Inglis

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 read-only IMAP folder(s) and NNTP newsgroup(s).