re: [OT] POSIX stuff

new topic     » goto parent     » topic index » view thread      » older message » newer message

Thanks andy.

I used freopen to implement redirection ( > >> < >& >>& ).
It won't work for piping, because freopen redirects a stream to a file.
freopen( char* file, char* filemode, stream )

In my implementation I created a pipe(). The two ends of the pipe are file 
_handles_, not files. For that I thought you could use fdopen:
stream = fdopen( int filehandle, char* mode);

But it doesn't want to redirect stdout or stdin, the input process still 
outputs to screen, rather than to the output process.

=====================================================
Mr Trick





>From: andy at systemzone.freeserve.co.uk
>Reply-To: EUforum at topica.com
>To: EUforum <EUforum at topica.com>
>Subject: re: [OT] POSIX stuff
>Date: Sun, 27 Apr 2003 22:10:01 +0100
>
>
>I'm not infront on a UNIX box right now but the freopen function might be
>worth  a look?
>
>Regards,
>
>Andy Cranston.
>
>At 04:08 AM 4/28/03 +1000, you wrote:
> >
> >
> >>From: mistertrik at hotmail.com
> >>How stupid of me! I scrolled straight past a unistd.h function called
> >>pipe().
> >>
> >>Nevermind, I think I can figure it out now... <slaps self in head>
> >
> >It seems I spoke too soon...
> >Apologies for cluttering up a euphoria mailing list with C questions...
> >
> >I have created the pipe, and forked to get the two separate processes.
> >How does one go about tying stdin to pipe read end in one process, and 
>tying
> >stdout to pipe write end in the other?
> >Atm it just uses stdout = pipeend[1] and stdout = pipeend[0];, quite
> >definitely good programming practice.
> >
> >On attempting to pipe ls to grep, a segmentation fault occured, but on
> >attempting to pipe ls to pico, there was no error, and it worked fine.
> >
> >I am very confused...
> >=====================================================
> >.______<-------------------\__
> >/ _____<--------------------__|===
> >||_    <-------------------/
> >\__| Mr Trick
> >
> >
> >TOPICA - Start your own email discussion group. FREE!
> >
> >
>
>
>TOPICA - Start your own email discussion group. FREE!
>
>

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu