diff options
Diffstat (limited to 'djgpp/djgpp.c')
-rw-r--r-- | djgpp/djgpp.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/djgpp/djgpp.c b/djgpp/djgpp.c index c928851b76..80a627e518 100644 --- a/djgpp/djgpp.c +++ b/djgpp/djgpp.c @@ -433,3 +433,22 @@ Perl_DJGPP_init (int *argcp,char ***argvp) strcpy (perlprefix,".."); } +int +djgpp_fflush (FILE *fp) +{ + int res; + + if ((res = fflush(fp)) == 0 && fp) { + Stat_t s; + if (Fstat(fileno(fp), &s) == 0 && !S_ISSOCK(s.st_mode)) + res = fsync(fileno(fp)); + } +/* + * If the flush succeeded but set end-of-file, we need to clear + * the error because our caller may check ferror(). BTW, this + * probably means we just flushed an empty file. + */ + if (res == 0 && fp && ferror(fp) == EOF) clearerr(fp); + + return res; +} |