comp.lang.ada
 help / color / mirror / Atom feed
From: sk <noname@myob.com>
To: comp.lang.ada@ada.eu.org
Subject: Re: Ada & Scripting
Date: Fri, 16 May 2003 15:57:57 -0500
Date: 2003-05-16T15:57:57-05:00	[thread overview]
Message-ID: <mailman.8.1053118053.22676.comp.lang.ada@ada.eu.org> (raw)
In-Reply-To: 1226841.70Sv0M8gQ7@linux1.krischik.com

Hi,

  > I have some C sources for 'popen' which show how this is
  > supposed to work. Now I "only" have to map the function to Ada.

...

  > I saw them. As I said 'popen' ony returns one of the
  > pipes - so I have to program my own version of 'popen'.

... and as I said, the method is 2 PIPES (not 'popen')

The routine (algorithm) goes, roughly, like so ...

<algorithm>

Create a PIPE for stdin
Create a PIPE for stdout
Create a PIPE for stderr

FORK

if child process

      DUP the stdin, stdout and stderr pipes

      Close the write end of the stdin pipe
      Close the read end of the stdout pipe
      Close the read end of the stderr pipe

      EXECUTE the program you choose to talk
           to through pipes.

else -- parent process

      Close the read end of the stdin pipe
      Close the write end of the stdout pipe
      Close the write end of the stderr pipe

      Read from the stdout or stderr pipes.

      Write to stdin pipe.

end if;

</algorithm>

Use the "select" or "poll" system calls in the parent
process to determine if the pipes are open, open but
blocked or closed.

There is no difficulty in implementing this algorithm
in Ada, but it is a very "C" way to do it. A more Ada
solution is to use Ada tasks or protected objects, but
there is still a 'fork' and 'exec' call involved since
this is the way a Linux system (and Windows I think)
implements the "pipe" concept. So, I tend to stick
to the parent/child fork and exec method retaining the
"C" way to do things.

-- 
-------------------------------------------------
-- Merge vertically for real address
--
--     s n p @ t . o
--      k i e k c c m
-------------------------------------------------





  reply	other threads:[~2003-05-16 20:57 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-05-10 12:07 Ada & Scripting kat-Zygfryd
2003-05-10 13:34 ` Preben Randhol
2003-05-10 19:10 ` Bobby D. Bryant
2003-05-10 20:28   ` kat-Zygfryd
2003-05-11  1:39     ` John R. Strohm
2003-05-11 10:12       ` kat-Zygfryd
2003-05-11 10:55         ` John R. Strohm
2003-05-11 11:23           ` kat-Zygfryd
2003-05-13  4:45             ` Bobby D. Bryant
2003-05-13 16:32               ` Wesley Groleau
2003-05-20 22:19               ` Randy Brukardt
2003-05-21 11:43                 ` Georg Bauhaus
2003-05-12  8:46     ` Preben Randhol
2003-05-12 12:09       ` Frank Piron
2003-05-12 14:31         ` Preben Randhol
2003-05-13  4:47         ` Bobby D. Bryant
2003-05-13 16:33 ` Martin Krischik
2003-05-14 15:22   ` Preben Randhol
2003-05-14 17:05     ` Martin Krischik
2003-05-14 18:51       ` sk
2003-05-15 16:47         ` Martin Krischik
2003-05-16 20:57           ` sk [this message]
2003-05-17  7:36             ` Martin Krischik
replies disabled

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