🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.os2.programmer.misc
Article #205

Problems Redirecting Stdout/Stderr

#205
From: Keith Bennett
Date: Thu, 01 Sep 1994 17:30
33 lines
2390 bytes
I have a PM app which consists of a process which starts another process
which in turn starts another process.  DosStartSession() is used to start  
the child processes.  I would like to redirect stdout
and stderr to separate files for each process.

I used _open() and dup2() to do the redirection, but no matter which
flags I passed to _open(), the contents of the file were always
overwritten.

Then I tried freopen().  All three process succeeding in opening the
output files, but only the first process could get any output in that
file.  The others had a file size of zero.  Thinking that it might be
related to a file buffer that didn't get flushed, I tried using
setbuf() to unbuffer the files.  That didn't change anything.

When I started #2 directly from the command line, the output
showed up.  I then thought that maybe #2 inherited the redirected
file handle from #1, and instead of redirecting again, simply output
some text using printf(), expecting it to show up in #1's file.  It
didn't.

By the way, I would also have liked to redirect both stdout and stderr
to the same file for each executable, but couldn't get that to work,
so I settled on two separate files for each process.

Can anyone shed some light on these issues?  Thanks very much.
- Keith

-- 
--------------------------------------------------------------------------
Keith Bennett                            Bennett Business Solutions, Inc.
C++/C Software Development               1852 Middlebridge Drive
kbennett@cpcug.org                       Silver Spring, MD USA 20906
Technical Details
Message-ID: <34533h$fg9@cpcug.org>
Path: arc1-ca.pugleaf.net!bga.com!news.sprintlink.net!hookup!yeshua.marcam.com!news.kei.com!MathWorks.Com!europa.eng.gtefsd.com!howland.reston.ans.net!gatech!newsxfer.itd.umich.edu!uunet!news1.digex.net!digex.net!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cd94,2da82d0fa8b93e78,start
X-Google-Attributes: gid10cd94,public
X-Google-Thread: 11307a,2da82d0fa8b93e78,start
X-Google-Attributes: gid11307a,public
X-Google-ArrivalTime: 1994-09-01 11:11:27 PST
Path: arc1-ca.pugleaf.net!bga.com!news.sprintlink.net!hookup!yeshua.marcam.com!news.kei.com!MathWorks.Com!europa.eng.gtefsd.com!howland.reston.ans.net!gatech!newsxfer.itd.umich.edu!uunet!news1.digex.net!digex.net!not-for-mail
From: kbennett@cpcug.org (Keith Bennett)
Newsgroups: comp.os.os2.programmer.misc,bit.listserv.os2-l
Subject: Problems Redirecting Stdout/Stderr
Date: 1 Sep 1994 13:30:25 -0400
Organization: Express Access Online Communications USA: 800-969-9090
Lines: 33
Message-ID: <34533h$fg9@cpcug.org>
NNTP-Posting-Host: cpcug.org