Re: [gtk-list] Re: retrieving data from another process



> >> My second question; I have to call another program (gcc) and
> >> get the output (STDOUT and STDERR) into data for my program.
>: stuff removed
> ds> If you want to get both stdout AND stderr then popen() won't do; I guess
> ds> you'll need to fork() and then exec() just after redirecting streams as
> ds> desired with pipe()/dup().  You stop reading when you get EOF, no need
> ds> for handlers IMHO.
> ds> -Daniel

	Yes, only stdout. stderr will never be on the  pipe.

> f = popen("cmd 2>&1", "r");
> redirects stdin and stdout.

	Well, that's stderr redirected to stdout. Both will go on the
	pipe. HOWEVER... When stdout is redirected it becomes buffered
	and unless your 'piped' command does something, your stderr
	messages will appear out of context. This is what I mean:

	Normal console execution:
		0: on stdout
		1: on stderr
		2: on stdout
    
	Piped or redirected to a file:
		1: on stderr
		0: on stdout
		2: on stdout

	If you don't care about it then no problem.

			Cheers,
				Emilio
-- 
D. Emilio Grimaldo Tunon       Compuware Europe B.V. (Uniface Lab)
Software Engineer	       Amsterdam, The Netherlands
emilio_tunon@nl.compuware.com  Tel. +31 (0)20 3116 200 ext. 413



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]