From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,1a7be6e64c98018a X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news1.google.com!proxad.net!newsfeed.stueberl.de!newsfeed.vmunix.org!news2.euro.net!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!feeder.news-service.com!post.news-service.com!news1.surfino.com!not-for-mail Message-ID: <6000144.7FP8lPn99l@linux1.krischik.com> From: Martin Krischik Subject: Re: Spawn : Get the output of the called program Newsgroups: comp.lang.ada Date: Wed, 06 Apr 2005 19:08:07 +0200 References: User-Agent: KNode/0.9.0 MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: 8Bit X-Complaints-To: abuse@surfino.com Organization: Surfino Gmbh NNTP-Posting-Host: 83.169.175.19 (83.169.175.19) NNTP-Posting-Date: Wed, 06 Apr 2005 20:00:21 +0200 X-Trace: 73b3d425423b5f60c0ab605499 Xref: g2news1.google.com comp.lang.ada:10308 Date: 2005-04-06T19:08:07+02:00 List-Id: 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