TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Ruud Senden
from: Thomas Seeling
date: 1996-03-25 00:02:44
subject: Redirection

Hallo, Ruud!

*** Am Donnerstag 21. M„rz 1996 um 20:08 schrieb Ruud Senden an All:

 RS> Suppose I have a program which reads it's input from stdin, and sends it's
 RS> output to stdout. This program has to run permanently in the background on
 RS> a WWW-server. A CGI-script on the WWW-server should be able to send and
 RS> receive information to the permanent process (so the CGI-script should be
 RS> able to put information on stdin of the permanent process, and read
 RS> information from stdout of the permanent process).

If you know the exact CGI/1.1 specs you already have the answer. You need a
special wrapper like you suggested, which has to be started as a GGI
script. It is not possible for the WWW server to interface to a
"permanent"ly running program, since it waits for the CGI script
to finish and get its return code.

You will want to redirect stdin/stdout to pipes created with pipe() or
DosCreatePipe() (you need to create two pipes if you want to redirect both
input and output of the child), then save the current state of
stdin/stdout, DosDupHandle() the respective end of the two pipes to the
handle numbers associated with stdin/stdout (0/1), call the CGI script and
then restore the previous associations of stdin/stdout. The child should
notice eof(stdin) when you close the write end of the pipe that belongs to
its stdin.


Tschau...Thomas

--- E3-32/1.11-32/2.50+
* Origin: Die TeX-Box +49-6034-1455 V.34 -930022 ISDN 24h (2:244/1130.42)
SEEN-BY: 50/99 78/0 270/101 620/243 711/401 409 410 413 430 808 809 934 955
SEEN-BY: 712/407 515 517 628 713/888 800/1 7877/2809
@PATH: 244/1130 24/999 2/777 396/1 270/101 712/515 711/808 809 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.