delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/07/19/07:01:42

Date: Sun, 19 Jul 1998 14:00:11 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: Jorge Ivan Meza Martinez <jimeza AT usa DOT net>
cc: djgpp AT delorie DOT com
Subject: Re: read stderr
In-Reply-To: <01bdb1c5$1f278800$0a1f1bc4@default>
Message-ID: <Pine.SUN.3.91.980719135948.32K-100000@is>
MIME-Version: 1.0

On Fri, 17 Jul 1998, Jorge Ivan Meza Martinez wrote:

> I use system to launch a child program, 
> it generates stdout and stderr,
> I am interested in take this data to be shown in my program,
> how can I do that in a portable way ?

If you only need to capture stdout, use `popen' and `pclose' instead
of `system'.

If you need stderr as well, you will need to redirect handle 2 to a
file (using `dup'/`open'/`dup2' paradigm) before you call either
`system' or `popen', and then read the redirected output from the file
after the child process returns.

All of the functions mentioned above are fairly portable.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019