Hi,
Unlikely to happen during normal use, but setvbuf(3) can fail
to allocate your buffer:
/* prog.c */
#include <stdio.h>
int
main(int argc, char *argv[])
{
if (setvbuf(stdout, NULL, _IOFBF, 0))
perror("setvbuf");
return 0;
}
This seems to force the allocation failure on my box:
$ ksh -c "ulimit -d 230 ; ./prog"
Not sure what the correct wording is for the ERRORS section.
Is it appropriate to specify that you can only get an allocation
failure under the particular circumstances described? Or is it
better to just write the standard line?, i.e.
"Insufficient storage space is available."
As a reader I would want to know more precisely how the
interface can fail. Still seems kind of messy. Maybe my
wording could be improved.
--
Scott Cheloha
Index: lib/libc/stdio/setvbuf.3
===================================================================
RCS file: /cvs/src/lib/libc/stdio/setvbuf.3,v
retrieving revision 1.4
diff -u -p -r1.4 setvbuf.3
--- lib/libc/stdio/setvbuf.3 26 Nov 2014 18:16:32 -0000 1.4
+++ lib/libc/stdio/setvbuf.3 29 Jul 2017 01:27:55 -0000
@@ -138,6 +138,10 @@ function will fail if:
The
.Fa stream
specified is not associated with a valid file descriptor.
+.It Bq Er ENOMEM
+Line or block buffering is requested,
+.Fa buf
+is NULL, and insufficient storage space is available.
.El
.Sh SEE ALSO
.Xr fclose 3 ,