Re: pg_dump return status..

Поиск
Список
Период
Сортировка
От Pete Forman
Тема Re: pg_dump return status..
Дата
Msg-id 14937.35349.648362.197502@kryten.bedford.waii.com
обсуждение исходный текст
Ответ на Re: pg_dump return status..  (ncm@zembu.com (Nathan Myers))
Ответы Re: pg_dump return status..  (Philip Warner <pjw@rhyme.com.au>)
Re: pg_dump return status..  (Bruce Momjian <pgman@candle.pha.pa.us>)
Список pgsql-hackers
Nathan Myers writes:> On Fri, Jan 05, 2001 at 11:20:43AM -0500, Tom Lane wrote:> > Philip Warner <pjw@rhyme.com.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> > correct.> > An fprintf returning 0 is a suspicious event; it's easy to imagine > cases
whereit 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
oldBSD-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
wecare?)> > If SunOS 4 is to remain a supported platform, the printf checks may > need to be special-cased for it.
 

Current Solaris is liable to problems still, though these are not
relevant to this thread.  printf() and fprintf() have always returned
the number of characters transmitted, or EOF for failure.  It is
sprintf() that has problems.

There are two versions of sprintf() available in SunOS 4 - 8.  The
standard one (ANSI C) in libc returns an int, the number of characters
written (excluding '\0').  The BSD version returns a char* which
points to the target.  If you have a -lbsd on your link line then you
get the BSD version.  There are no compiler errors, just run time
errors if you rely on the return from sprintf() being the number of
characters.  The workaround is to put an extra -lc on the link line
before the -lbsd if your code needs both standard sprintf() and some
other BSD function.

Ultrix is documented as having the same behaviour as Solaris.  I don't
know about NeXTSTEP/OPENSTEP/GNUStep.
-- 
Pete Forman                 -./\.- Disclaimer: This post is originated
WesternGeco                   -./\.-  by myself and does not represent
pete.forman@westerngeco.com     -./\.-  opinion of Schlumberger, Baker
http://www.crosswinds.net/~petef  -./\.-  Hughes or their divisions.


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Tatsuo Ishii
Дата:
Сообщение: Re: ALL, ANY bug?
Следующее
От: Pete Forman
Дата:
Сообщение: Re: patch: contrib/pgcrypto sanity