mcedit problem (2)

Andrew V. Samoilov kai at cmail.ru
Sat Dec 22 12:53:42 UTC 2001


Hi, Pavel!
>
>> > >404         for (;;) {
>> > >405             c = fgetc (f);
>> > >406             if (c == EOF) {
>> > >407                 if (errno == EINTR)
>> > >408                     continue;
>> > >---
>> > 
>> > I cannot reproduce this, but it is possible if previous system call was 
>> > interrupted.
>
>Exactly.  Just add "errno = EINTR" in the beginning of the function and 
>you have the problem.
>
>> > fgetc returns -1 on error and on end of file, so additional check needed.
>
>It's interesting that "info glibc" (glibc-2.2.4) doesn't mention what
>fgetc() returns if the call is interrupted before any single character has
>been read.  I would prefer not to rely on the assumption that it's EOF
>(maybe it's documented somewhere else, but it's better to play safe).
>
>>  I've also tried to reproduce this w/o success. I think we need to call
>> clearerr(_unlocked?) on line 408 above. (If found some usenet posts that
>> indicated that this is indeed necessary on Solaris. (Sorry, I that was
>> last week and I didn't save them.))
>
>Actually, clearerr() would clear the EOF state from the descriptor, which
>would not help.
>
>What needs to be done is "errno = 0".  I'm committing this patch.

And what about systems where errno is a function?

Regards,
Andrew.




More information about the mc-devel mailing list