summaryrefslogtreecommitdiff
path: root/perlio.c
diff options
context:
space:
mode:
authorNick Ing-Simmons <nik@tiuk.ti.com>2003-02-01 09:26:31 +0000
committerNick Ing-Simmons <nik@tiuk.ti.com>2003-02-01 09:26:31 +0000
commit4d94824190f1d3f4307c94794486b277afd6e971 (patch)
tree4a0cacd2149951dc98c4453022d904b2fe51e411 /perlio.c
parente67eb5fe02942880b40697f65cd8c3bc3d42c514 (diff)
downloadperl-4d94824190f1d3f4307c94794486b277afd6e971.tar.gz
Michael Schroeder's fix for re-try if stdio ops after
interrupts. (Calls to PERL_ASYNC_CHECK added by NI-S). p4raw-id: //depot/perlio@18611
Diffstat (limited to 'perlio.c')
-rw-r--r--perlio.c42
1 files changed, 28 insertions, 14 deletions
diff --git a/perlio.c b/perlio.c
index a9228b4766..25c13804e6 100644
--- a/perlio.c
+++ b/perlio.c
@@ -2860,20 +2860,26 @@ PerlIOStdio_read(pTHX_ PerlIO *f, void *vbuf, Size_t count)
{
FILE *s = PerlIOSelf(f, PerlIOStdio)->stdio;
SSize_t got = 0;
- if (count == 1) {
- STDCHAR *buf = (STDCHAR *) vbuf;
- /*
- * Perl is expecting PerlIO_getc() to fill the buffer Linux's
- * stdio does not do that for fread()
- */
- int ch = PerlSIO_fgetc(s);
- if (ch != EOF) {
- *buf = ch;
- got = 1;
+ for (;;) {
+ if (count == 1) {
+ STDCHAR *buf = (STDCHAR *) vbuf;
+ /*
+ * Perl is expecting PerlIO_getc() to fill the buffer Linux's
+ * stdio does not do that for fread()
+ */
+ int ch = PerlSIO_fgetc(s);
+ if (ch != EOF) {
+ *buf = ch;
+ got = 1;
+ }
}
+ else
+ got = PerlSIO_fread(vbuf, 1, count, s);
+ if (got || errno != EINTR)
+ break;
+ PERL_ASYNC_CHECK();
+ errno = 0; /* just in case */
}
- else
- got = PerlSIO_fread(vbuf, 1, count, s);
return got;
}
@@ -2938,8 +2944,16 @@ PerlIOStdio_unread(pTHX_ PerlIO *f, const void *vbuf, Size_t count)
SSize_t
PerlIOStdio_write(pTHX_ PerlIO *f, const void *vbuf, Size_t count)
{
- return PerlSIO_fwrite(vbuf, 1, count,
- PerlIOSelf(f, PerlIOStdio)->stdio);
+ SSize_t got;
+ for (;;) {
+ got = PerlSIO_fwrite(vbuf, 1, count,
+ PerlIOSelf(f, PerlIOStdio)->stdio);
+ if (got || errno != EINTR)
+ break;
+ PERL_ASYNC_CHECK();
+ errno = 0; /* just in case */
+ }
+ return got;
}
IV