Re: Strange intermittent EIO error when writing to stdout sincev3.8.0

From: Markus Trippelsdorf
Date: Thu Jun 06 2013 - 14:41:39 EST


On 2013.06.06 at 18:31 +0100, David Howells wrote:
> Markus Trippelsdorf <markus@xxxxxxxxxxxxxxx> wrote:
>
> > OSError: [Errno 5] Input/output error
> >
> > Basically 'emerge' just writes the build output to stdout in a loop:
>
> I've just upgraded to kernel-3.9.4-200.fc18.x86_64 and I'm now regularly
> seeing something very similar from the tee run by "fedpkg local" to log its
> output when building a cross-compiler gcc RPM:
>
> tee: standard output: Input/output error
> tee: write error
>
> Slapping strace on tee after the "Input/output error" line has occurred shows
> that tee is still running and still pushing lines from its stdin to the output
> named on its command line, but has ceased writing to its stdout.

tee uses the same loop as portage, but keeps going in case of an EIO:

/* In the array of NFILES + 1 descriptors, make
the first one correspond to standard output. */
descriptors[0] = stdout;
files[0] = _("standard output");
setvbuf (stdout, NULL, _IONBF, 0);

for (i = 1; i <= nfiles; i++)
{
descriptors[i] = (STREQ (files[i], "-")
? stdout
: fopen (files[i], mode_string));
if (descriptors[i] == NULL)
{
error (0, errno, "%s", files[i]);
ok = false;
}
else
setvbuf (descriptors[i], NULL, _IONBF, 0);
}

while (1)
{
bytes_read = read (0, buffer, sizeof buffer);
if (bytes_read < 0 && errno == EINTR)
continue;
if (bytes_read <= 0)
break;

/* Write to all NFILES + 1 descriptors.
Standard output is the first one. */
for (i = 0; i <= nfiles; i++)
if (descriptors[i]
&& fwrite (buffer, bytes_read, 1, descriptors[i]) != 1)
{
error (0, errno, "%s", files[i]);
descriptors[i] = NULL;
ok = false;
}
}

--
Markus
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/