Gil,

Maybe that is one of the "enhancements" ? :-)

Actually this seems to be an issue with the stream buffering strategy.
See the C/C++ RTL Ref for "setvbuf()".   Maybe you need to explicitly call
setvbuf() for stdout/stderr with __LIBASCII ??

Kirk Wolf
Dovetailed Technologies
http://dovetail.com


On Tue, Jul 9, 2013 at 6:12 PM, Paul Gilmartin <[email protected]> wrote:

> My test program, isbuffer.c:
>
> /* Doc: demonstrate buffering of stdout and stderr */
> #include <stdio.h>
>
> int main( void ) {
>     int I;
>
>     for ( I = 0; I<5; I++ ) {
>         fprintf( stdout, "Record %2d to stdout\n", I );
>         fprintf( stderr, "Record %2d to stderr\n", I ); }
>
>     return( 0 ); }
>
> ... when compiled and executed with the C/C++ compiler on z/OS 1.13 prints:
>
> SPPG@MVS3:136$ cd ../OS390
> SPPG@MVS3:138$ gmake isbuffer &&amp; ./isbuffer
> gmake: `isbuffer' is up to date.
> Record  0 to stdout
> Record  0 to stderr
> Record  1 to stdout
> Record  1 to stderr
> Record  2 to stdout
> Record  2 to stderr
> Record  3 to stdout
> Record  3 to stderr
> Record  4 to stdout
> Record  4 to stderr
>
> ... the writes to stdout and stderr come out interleaved, in the order
> in which they were executed.  However, when I compile in Enhanced
> ASCII mode and link with xplink, I get:
>
> SPPG@MVS3:145$ cd ../ASCII
> SPPG@MVS3:146$ gmake isbuffer &&amp; ./setascii ./isbuffer
> unset LC_CTYPE; \
> c99 -I.. -D_ALL_SOURCE   -Wa,"ASA,RENT" -Wl,xplink,EDIT=NO -Wc,dll,ascii
> -o isbuffer isbuffer.o /usr/lib/Xaw.x /usr/lib/SM.x /usr/lib/ICE.x
> /usr/lib/X11.x -lcurses
> Record  0 to stderr
> Record  1 to stderr
> Record  2 to stderr
> Record  3 to stderr
> Record  4 to stderr
> Record  0 to stdout
> Record  1 to stdout
> Record  2 to stdout
> Record  3 to stdout
> Record  4 to stdout
>
> ... all the writes to stderr come out first, and stdout appears to be
> using a lazy buffer.  Is this documented?  Is there a standard
> involved?  Or just a good argument for issuing prompts to stderr
> rather than to stdout in an interactive program?  (Or for using
> fflush().)
>
> -- gil
>
> ----------------------------------------------------------------------
> For IBM-MAIN subscribe / signoff / archive access instructions,
> send email to [email protected] with the message: INFO IBM-MAIN
>

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to