comp.lang.ada
 help / color / mirror / Atom feed
From: Martin Krischik <krischik@users.sourceforge.net>
Subject: Re: Spawn : Get the output of the called program
Date: Wed, 06 Apr 2005 19:08:07 +0200
Date: 2005-04-06T19:08:07+02:00	[thread overview]
Message-ID: <6000144.7FP8lPn99l@linux1.krischik.com> (raw)
In-Reply-To: c1m8xs96i37y.108myta3hw08w$.dlg@40tude.net

Dmitry A. Kazakov wrote:

> On Wed, 06 Apr 2005 16:43:31 +0200, Jean-Baptiste CAMPESATO wrote:
> 
>> Le Wed, 06 Apr 2005 12:21:14 +0200, Jean-Baptiste CAMPESATO a ᅵcritᅵ:
>> 
>>> I want to called a programm (like the Spawn Procedure in GNAT.OS_lib)
>>> but i wannt to get the output fo this program.
>>> Do you know how can i get the output with Spawn, or another
>>> function/procedure to do that ?
>>> Thanks
>> 
>> Thanks everybody :).
>> I will read http://adacl.sourceforge.net/ and a doc about pipes.
> 
> I don't like the design of either library because many programs heavily
> use stderr. For them to make it useful one needs all three pipes.

Excuse me! I wrote AdaCL.OS.Command explicitly for that purpose - to attach
to all three pipes:

   --
   --  Attach a Text_IO file to the Standart Input of the process
   --
   procedure Attach_In (
      --  Object itself.
      This : in out Object'Class;
      --  Text IO to be attached
      File : in out Ada.Text_IO.File_Type);

   --
   --  Attach a Text_IO file to the Standart Output of the process
   --
   procedure Attach_Out (
      --  Object itself.
      This : in out Object'Class;
      --  Text IO to be attached
      File : in out Ada.Text_IO.File_Type);

   --
   --  Attach a Text_IO file to the Error Output of the process
   --
   procedure Attach_Error (
      --  Object itself.
      This : in out Object'Class;
      --  Text IO to be attached
      File : in out Ada.Text_IO.File_Type);

> Further,  
> the stderr pipe should be read out asynchronously from a parallel task.

And yes AdaCL.OS.Command has asynchronously execution as well:

   --
   --  Execution Mode
   --
   type Mode
   is (
      --  Start Process syncronous.
      Sync,
      --  Start Process asyncronous.
      Async,
      --  Start Process asyncronous and redirect standart in and
      --  standart out.
      In_Out);

> Otherwise, you are risking to fall into a deadlock if the pipe buffer size
> is limited, which is often the case. Therefore, you need two procedures:
> Spawn to invoke the program and Wait to wait for its completion.

   --
   --  Wait for the end of the command - only for Async and In_Out
   --
   procedure Wait (
      --  Object itself.
      This : in out Object);

I know that AdaCL is not perfect - but before you bash it you should at
least pick some feature which really isn't there.

Martin
-- 
mailto://krischik@users.sourceforge.net
Ada programming at: http://ada.krischik.com




  reply	other threads:[~2005-04-06 17:08 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-06 10:21 Spawn : Get the output of the called program Jean-Baptiste CAMPESATO
2005-04-06 10:52 ` Jean-Baptiste CAMPESATO
2005-04-06 11:15   ` Pascal Obry
2005-04-06 11:24     ` Jean-Baptiste CAMPESATO
2005-04-06 13:36   ` Martin Krischik
2005-04-06 13:34 ` Martin Krischik
2005-04-06 14:09 ` Marc A. Criley
2005-04-06 14:43 ` Jean-Baptiste CAMPESATO
2005-04-06 15:13   ` Dmitry A. Kazakov
2005-04-06 17:08     ` Martin Krischik [this message]
2005-04-07  9:33       ` Dmitry A. Kazakov
2005-04-12  9:28 ` Duncan Sands
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox