On Fri, Jan 05, 2001 at 11:20:43AM -0500, Tom Lane wrote:
> Philip Warner <pjw(at)rhyme(dot)com(dot)au> writes:
> > how do I
> > check for a failed write in a way that works on all Unixes? Is the
> > following OK:
> > - fwrite: ok if return value equals item count
> > - fprintf: ok if return value > 0.
> > - fputc: ok if != EOF
> Probably fprintf() >= 0 --- according to my specs, it returns the number
> of chars emitted, or a negative value on error. The other two are
An fprintf returning 0 is a suspicious event; it's easy to imagine
cases where it makes sense, but I don't think I have ever coded one.
Probably >N (where N is the smallest reasonable output, defaulting
to 1) may be a better test in real code.
As I recall, on SunOS 4 the printf()s don't return the number of
characters written. I don't recall what they do instead, and have
no access to such machines any more.
Other old BSD-derived systems are likely to have have wonky return
values/types on the printf()s. Looking at the list of supported
platforms, none jump out as likely candidates, but in the "unsupported"
list, Ultrix and NextStep do. (Do we care?)
If SunOS 4 is to remain a supported platform, the printf checks may
need to be special-cased for it.
In response to
pgsql-hackers by date
|Next:||From: Ian Lance Taylor||Date: 2001-01-05 22:26:13|
|Subject: Re: pg_dump return status..|
|Previous:||From: Ian Lance Taylor||Date: 2001-01-05 22:13:27|
|Subject: Re: Recursion and SPI|
pgsql-general by date
|Next:||From: Uro Gruber||Date: 2001-01-05 22:17:29|
|Subject: PHP and PostgreSQL|
|Previous:||From: The Hermit Hacker||Date: 2001-01-05 22:03:14|
|Subject: Re: mysql data to pgsql|