chicken-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-hackers] [PATCH] Fix another problem with receiving signals whi


From: Peter Bex
Subject: [Chicken-hackers] [PATCH] Fix another problem with receiving signals while read()ing
Date: Sat, 3 Nov 2012 21:56:38 +0100
User-agent: Mutt/1.4.2.3i

Hi all,

Today I noticed an intermittent failure in the scsh-process tests.
After some debugging, it turned out that my last patch for
fast_read_string_from_file() was incomplete; if we receive a signal
while reading and nothing has been read yet, fread() will return
exactly 0 bytes and set an error condition due to EINTR.
fast_read_string_from_file will then take the branch in library.scm:125:

...
} else if (ferror (fp)) {
  if (0 == m) {
    return C_SCHEME_FALSE;
  }
}
...

This will not clear the error.  I think this extra case at the start
is just mistaken, and should be ripped out.  Attached is a patch which
does exactly that.  This should simplify the function to be more
understandable.  I've also taken the opportunity to replace some of
those evil []-style brackets with proper parentheses ;)

I'm unsure about fast_read_line_from_file().  At least I can't trigger
the error with the test program when using read-line instead of
read-string, so I guess this particular error situation is handled
correctly.

I've also attached a test program which triggers this bug on NetBSD.
On Linux I wasn't able to reproduce this bug (I think I've pointed
out before that it doesn't seem to return with EINTR on signals but
just restarts the read itself).  Again I haven't added this to the
test suite because it's so specific to (Net)BSD.

Cheers,
Peter
-- 
http://sjamaan.ath.cx
--
"The process of preparing programs for a digital computer
 is especially attractive, not only because it can be economically
 and scientifically rewarding, but also because it can be an aesthetic
 experience much like composing poetry or music."
                                                        -- Donald Knuth

Attachment: 0001-Simplify-and-fix-fast_read_string_from_file-so-it-wi.patch
Description: Text document

Attachment: test.scm
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]