[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: fpurge on z/OS

From: Chet Ramey
Subject: Re: fpurge on z/OS
Date: Sun, 19 Apr 2009 21:20:52 -0400
User-agent: Thunderbird (Macintosh/20090302)

Bruno Haible wrote:

> Thanks for explaining. I think an alternative for bash would be to
> temporarily set the file descriptor to point to /dev/null and do a
> second fflush. Like this (error checking omitted):
>   FILE *fp = ... /* stdout or stderr */;
>   if (fflush (fp) < 0)
>     {
>       fpurge (fp);
> #else
>       int fd = fileno (fp);
>       int saved_fd = dup (fd);
>       int sink_fd = open ("/dev/null", O_WRONLY);
>       dup2 (sink_fd, fd);
>       fflush (fp);
>       close (sink_fd);
>       dup2 (saved_fd, fd);
>       close (saved_fd);
> #endif
>     }

That seems like a lot of trouble (and there's more that you have here,
since bash also has to worry about the close-on-exec state of the file
descriptor).  A simple solution is to turn the #error into a #warning,
and add a return 0 to make the function into a no-op, on the assumption
that those versions of libc for which this is a problem (later versions
of glibc) already provide fpurge.


``The lyf so short, the craft so long to lerne.'' - Chaucer

Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/

reply via email to

[Prev in Thread] Current Thread [Next in Thread]