[mercury-users] Convert posix__fd to io__stream

Ondrej Bojar obo at cuni.cz
Thu Feb 9 02:32:37 AEDT 2006


Hi.

I'm using the collection of posix modules from mercury-extras to fork my 
process and connect the father and child with a pair of pipes. I need 
the father and the child to exchange some mercury terms back and forth. 
term_io__read_term and io__write are a good solution.

The child part is then easy, it's stdin and stdout are redirected to the 
pipes before the child is actually executed, so read_term and write are 
directly usable.

However, there is a problem on the father side: posix.m provides me with 
file descriptors for the father's pipe ends, not io__{input,output}_streams.

So far, I hacked it so that I replace stdout (using posix function dup), 
call io__write and replace stdout back. This is clearly a dangerous 
trick and the stream content indeed gets combined from several unflushed 
buffers.

What is the correct way of redirecting io__write to a file descriptor 
and read_term to read from a file descriptor?

Thanks,
   Ondrej.

-- 
Ondrej Bojar (mailto:obo at cuni.cz)
http://www.cuni.cz/~obo
--------------------------------------------------------------------------
mercury-users mailing list
post:  mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the users mailing list