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=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=unavailable autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,34b29f7884ececc8 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-05-16 13:47:35 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!nntp.cs.ubc.ca!freenix!enst.fr!not-for-mail From: sk Newsgroups: comp.lang.ada Subject: Re: Ada & Scripting Date: Fri, 16 May 2003 15:57:57 -0500 Organization: ENST, France Message-ID: References: <1352155.Gs21sEmXl2@linux1.krischik.com> <1419124.iFzRYCrhqu@linux1.krischik.com> <1226841.70Sv0M8gQ7@linux1.krischik.com> NNTP-Posting-Host: marvin.enst.fr Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Trace: avanie.enst.fr 1053118054 24617 137.194.161.2 (16 May 2003 20:47:34 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Fri, 16 May 2003 20:47:34 +0000 (UTC) To: comp.lang.ada@ada.eu.org Return-Path: User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.1) Gecko/20020828 X-Accept-Language: en-us X-BeenThere: comp.lang.ada@ada.eu.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: comp.lang.ada mail to news gateway List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Xref: archiver1.google.com comp.lang.ada:37410 Date: 2003-05-16T15:57:57-05:00 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 ... 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; 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 -------------------------------------------------