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 X-Google-Thread: 103376,6f94a58adaa49034,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-05-16 03:19:16 PST Path: archiver1.sj.google.com!newsfeed.google.com!newsfeed.stanford.edu!news.tele.dk!193.251.151.101!opentransit.net!jussieu.fr!enst!enst.fr!not-for-mail From: =?iso-8859-1?Q?Torbj=F6rn?= Karfunkel Newsgroups: comp.lang.ada Subject: Return value of system call (newbie question) Date: Wed, 16 May 2001 12:08:54 +0200 Organization: ENST, France Sender: comp.lang.ada-admin@ada.eu.org Message-ID: Reply-To: comp.lang.ada@ada.eu.org NNTP-Posting-Host: marvin.enst.fr Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: avanie.enst.fr 990008355 43563 137.194.161.2 (16 May 2001 10:19:15 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Wed, 16 May 2001 10:19:15 +0000 (UTC) To: comp.lang.ada@ada.eu.org Return-Path: Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org X-Mailman-Version: 2.0.3 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: comp.lang.ada mail<->news gateway List-Unsubscribe: , List-Archive: Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org Xref: archiver1.sj.google.com comp.lang.ada:7552 Date: 2001-05-16T12:08:54+02:00 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) Result := OtterCall(Value => ("/home/toka/otter/otter-3.0.6/source/otter " & "< /home/toka/exjobb/model_checker/nyare/" & ("sat" & Natural'Image(K)(2..Natural'Image(K)'Last) & ".in") & " > /home/toka/exjobb/model_checker/nyare/" & ("satresult" & Natural'Image(K)(2..Natural'Image(K)'Last) & ".oout"))); Result := OtterCall(Value => ("/home/toka/otter/otter-3.0.6/source/otter " & "< /home/toka/exjobb/model_checker/nyare/" & ("taut" & Natural'Image(K)(2..Natural'Image(K)'Last) & ".in") & " > /home/toka/exjobb/model_checker/nyare/" & ("tautresult" & Natural'Image(K)(2..Natural'Image(K)'Last) & ".oout"))); 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? 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 RETURN VALUE The value returned is 127 if the execve() call for /bin/sh fails, -1 if there was another error and the return code of the command otherwise. If the value of string is NULL, system() returns nonzero if the shell is available, and zero if not. system() does not affect the wait status of any other children. Grateful for assistance /Torbj�rn Karfunkel