[mercury-users] How to capture the io stream for call_system/4?

Ondrej Bojar bojar at csse.unimelb.edu.au
Tue Mar 27 13:55:24 AEST 2007


The module I'm attaching did not make it to the Manarchive yet, because it's not 
failsafe enough and contains weird workarounds for some things. You can use it 
as a sample, but I would actually suggest that we try to develop such a module 
in Manarchive together, because I need it as well.

exchange.m defines predicates launching a subprocess and exchanging line 
messages with it.

Another big drawbacks are:
- You can provide the *string* of command and args only, and shell crunches
   that, so you have all the stupid quotation issues;
   Providing list of args and a command name is definitely a missing alternative
- No proper error handling is done. What I ultimately want is to explicitly
   return signal/error code as an alternative to a message read.

Let me know if you were interested to start a proper Manarchive package (say 
'processes') development.

Cheers, O.

Peter Wang wrote:
> On 2007-03-25, doug.auclair at logicaltypes.com <doug.auclair at logicaltypes.com> wrote:
>> Dear all,
>> Is there a way to redirect the (output, specifically) io of
>> io.call_system/4 so that Mercury can process it as a string?
> Use a combination of pipe, fork, dup*, exec*, wait*.  Those are
> available in the posix binding in extras.  An easier way would be to
> make a binding to the popen() function.
> Peter
> --------------------------------------------------------------------------
> mercury-users mailing list
> Post messages to:       mercury-users at csse.unimelb.edu.au
> Administrative Queries: owner-mercury-users at csse.unimelb.edu.au
> Subscriptions:          mercury-users-request at csse.unimelb.edu.au
> --------------------------------------------------------------------------

Ondrej Bojar (mailto:obo at cuni.cz / bojar at ufal.mff.cuni.cz)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: exchange.m
Type: text/x-objcsrc
Size: 8298 bytes
Desc: not available
URL: <http://lists.mercurylang.org/archives/users/attachments/20070327/2208d6c3/attachment.bin>

More information about the users mailing list