HP3000-L Archives

September 1995, Week 1

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Steve Elmer <[log in to unmask]>
Reply To:
Steve Elmer <[log in to unmask]>
Date:
Mon, 4 Sep 1995 23:01:15 GMT
Content-Type:
text/plain
Parts/Attachments:
text/plain (54 lines)
Geoff Harper ([log in to unmask]) wrote:
: Greetings,
 
:      Can someone explain where C's printf sends its data to, and how it
: arrives at selecting the destination?
 
The printf function writes to a stream.  Streams are buffered in the C
library.  Therefore, data can sit in the buffer for a while before going
to the actual file.  The recommendation of using fflush() and _exit() is
excellent for the observed problems.  Note that this will not necessarily
help when multiple processes are writing to the same file.
 
:      Now, when compiled under the POSIX shell, the printfs go to the
: web browser, but the PRINT intrinsic goes to the $STDLIST of the web
: server job.  When compiled at the MPE prompt (and then using the MPE
: NEWLINK command to establish a link to the program in cgi-bin directory),
: both the printfs and the PRINT go to the $STDLIST of the web server job.
 
The PRINT intrinsic is a privilege write to MPE file number 1.  This file
has traditionally been difficult to redirect :)  When the shell does its
redirection with the ">" operator, the PRINT intrinsic will not see that.
(There is a fix in the works for this)
 
Similarily, your web browser probably redirected the C stdout file before
creating your cgi-bin child.  Again, PRINT doesn't know about that.  If
that's a problem, then PRINT shouldn't be used in this context.  After
there's a fix, this problem should go away.
 
To avoid confusion, "compiled under the POSIX shell" should really be
"compiled and/or linked with the POSIX C library" and "compiled at the
MPE prompt" should really be "compiled and/or linked with the standard
C library.  That is, if that's what you really mean.  The existence of
2 libraries on the system is rather confusing at times, and it helps to
be clear which one is indicated.
 
:      If you run this program interactively at either the shell or the
: MPE prompt, the PRINT will appear before the printfs, so they're obviously
: not getting to the screen the same route.
 
Buffering, see above.
 
:      What I'm trying to accomplish is to have a COBOL (yes... I know, why?)
: program, compiled at the MPE prompt, with a file link in cgi-bin
: directory (I *have* to link it - it aborts if I simply copy it over there
: and try to run it) to handle some POST method forms processing.
:      Can someone tell me if/how I might be able to direct my COBOL output
: to the same channel printf is using to get to the web browser?
 
Until the redirection fix is implemented, you will have to use some workaround.
The simplest thing that comes to mind is to send your COBOL output to a file
and have the cgi-bin script send it to the stdout.
 
Steve

ATOM RSS1 RSS2