Re: mcedit problem (2)
- From: Oskar Liljeblad <oskar osk mine nu>
- To: Pavel Roskin <proski gnu org>
- Cc: Björn Eriksson <mdeans algonet se>, mc-devel gnome org
- Subject: Re: mcedit problem (2)
- Date: Sat, 22 Dec 2001 14:24:10 +0100
On Friday, December 21, 2001 at 18:23, Pavel Roskin wrote:
> Hi, Bj?rn!
>
> > > >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.
The right fix is really this:
for (;;) {
c = fgetc(f);
if (c == EOF) {
if (ferror(f) && errno == EINTR)
continue;
fgetc only changes errno if there's an error. Even if errno != 0, prior to
calling fgetc, fgetc won't change it. The only way to check for an error
is to use ferror(f). If ferror(f) is true then errno has been updated as
well.
Regards,
Oskar Liljeblad (oskar osk mine nu)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]