|
Message-ID: <20120317203323.GB31153@brightrain.aerifal.cx> Date: Sat, 17 Mar 2012 16:33:23 -0400 From: Rich Felker <dalias@...ifal.cx> To: musl@...ts.openwall.com Subject: Re: Bug or correct behavior? On Sat, Mar 17, 2012 at 05:24:26PM +0100, finkler wrote: > Hi there, > > I attached a little program which reads from a freopen'd stdin in an > infinite loop. > With glibc I can then monitor the opened file, meaning if I write to > it from another process, my never-dying program can read and print > it. > With musl nothing happens. > Is this some glibc quirk or is it a bug in musl? Your code depends on glibc bug number 1190: http://sourceware.org/bugzilla/show_bug.cgi?id=1190 POSIX requires the EOF status of stdio streams to be sticky, i.e. the EOF flag for a stream is set when it reaches EOF, and all subsequent reads have to check that EOF flag and fail if it's set. To clear the EOF flag you can use clearerr or rewind/fseek. glibc ignores this part of the standard and ignores the EOF flag when attempting to read. To fix your code, simply call clearerr(stdin) after hitting EOF. Rich
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.