Mail Archives: djgpp/1995/11/06/15:16:47

Date: Mon, 6 Nov 1995 14:42:22 -0500
From: kagel AT quasar DOT bloomberg DOT com
To: A DOT APPLEYARD AT fs2 DOT mt DOT umist DOT ac DOT uk
Cc: DJGPP AT sun DOT soe DOT clarkson DOT edu
Subject: Re: Getting the return code of a program called by a Gnu C program
Reply-To: kagel AT ts1 DOT bloomberg DOT com

   From: "A.Appleyard" <A DOT APPLEYARD AT fs2 DOT mt DOT umist DOT ac DOT uk>
   Date: Mon, 6 Nov 1995 17:02:45 GMT

     If a program does this:-
     int i = system("MIAOW");
     /* MIAOW.EXE is a program that runs and then exits with fault code N */
     How can the Gnu C/C++ program find the error code that MIAOW.EXE returned?

System() runs it's argument by handing it to your shell and returns the exit
code of the shell, not the executed program/script.  If the shell is not well 
behaved, and COMMAND.COM certainly qualifies as badly behaved, and does not 
report the exit status of such a command, then system() cannot report this.

Your best bets are 1) Use a different shell (ARGGGGHHH!  I hate when folk tell
me that!)  2) Perform your own fork()/exec() of "MIAOW.EXE" directly using
wait() to retrieve the exit code. 

Having said this, do we have wait() implemented in DJGPP?

OOO, OOO, OOO: Sneaky idea...  Try:

	putenv( "COMSPEC=MIAOW.EXE" ); SYSTEM( "" );

It  C O U L D  work ;}  I can't try it now, but, if you do let me know.

Art S. Kagel, kagel AT ts1 DOT bloomberg DOT com

Variety is the soul of pleasure.  --  Aphra Behn

- Raw text -

  webmaster     delorie software   privacy  
  Copyright 2019   by DJ Delorie     Updated Jul 2019