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-Language: ENGLISH,ASCII X-Google-Thread: 103376,6f94a58adaa49034 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-05-16 08:56:08 PST Path: archiver1.sj.google.com!newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newshub2.home.com!news.home.com!news1.rdc1.sfba.home.com.POSTED!not-for-mail Message-ID: <3B02A2F7.5F1FD06B@home.com> From: Mark Biggar X-Mailer: Mozilla 4.77 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Return value of system call (newbie question) References: Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Date: Wed, 16 May 2001 15:56:08 GMT NNTP-Posting-Host: 65.3.211.243 X-Complaints-To: abuse@home.net X-Trace: news1.rdc1.sfba.home.com 990028568 65.3.211.243 (Wed, 16 May 2001 08:56:08 PDT) NNTP-Posting-Date: Wed, 16 May 2001 08:56:08 PDT Organization: Excite@Home - The Leader in Broadband http://home.com/faster Xref: archiver1.sj.google.com comp.lang.ada:7565 Date: 2001-05-16T15:56:08+00:00 List-Id: Torbj�rn Karfunkel wrote: > > I'm executing an external program from within an Ada program by using > > function OtterCall(Value : String) return Integer; > pragma Import(C, OtterCall, "system"); > > The program that is called upon, Otter, is called with the syntax > > otter output-file > > and the calls look like this (several calls to each are made) >... > Two problems have arisen: > 1) The first call to otter was executed normally and produced the > outfile satresult0.oout, > but the second call, which I thought would produce the outfile > tautresult0.oout, produced > an outfile named tautresult0.oout0.oout. > It seems that some part of the Value string from the previous call > is appended to the end > of the next. I solved this problem by appending a sequence of > blanks to the end of the Value > strings, but this seems unnecessary. Could anyone give an > explanation to this behavior? Yes, the code is reusing a memory buffer to construct the argument string. But, the routine system probably expects a terminating nul character on it's input string. Add a '& ASCII.NUL' to your argument or use the To_C conversion call from Interfaces.C. > 2) The value of Result is 26624. The program executed, Otter, produces > exit codes, and I would > like to get access to this exit code in some way instead of systems > return value. How is this > accomplished? The manual on system says This will be quite a bit more complicated and not as portable as using "system" as you will have to duplicate what "system" does internally and that varies with what operating system you are running under. On Unix/Linux you wil have to do 'fork' and 'exec' calls and then a 'wait' call to await the termination of the program. the return value you are looking for is embedded the return value of the 'wait' call as a bit field. On Windows what you have to do is completely different. -- Mark Biggar mark@biggar.org