Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ > Re: Catching ex...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 8 of 10 Topic 45813 of 47006
Post > Topic >>

Re: Catching exit code before program termination

by titanandrews <titanandrews@[EMAIL PROTECTED] > May 8, 2008 at 05:36 PM

On May 8, 5:28 pm, Rolf Magnus <ramag...@[EMAIL PROTECTED]
> wrote:
> titanandrews wrote:
> > On May 8, 2:30 pm, Martin York <Martin.YorkAma...@[EMAIL PROTECTED]
> wrote:
> >> On May 8, 9:05 am, titanandrews <titanandr...@[EMAIL PROTECTED]
> wrote:
>
> >> > Does anyone know if this can be done?
>
> >> Yes. But not that way.
> >> If you bring up cmd.exe
>
> >> run the application in cmd.exe
> >> Then you can print the exit code via the variabel %ERRORLEVEL%
>
> >> <command>
> >> echo %ERRORLEVEL%
>
> >> If you want to do it automatically just wrap it all in a small script
> >> that runs the code and then prints %ERRORLEVEL%
>
> >> On Unix/Linux systems you can do the same thing.
> >> The exact code depends on what shell you are using:
>
> >> In tcsh
> >> ./<COMMAND>
> >> echo $?
>
> > Thanks. But thats after the process has ended. By then, it's too
> > late. :(
>
> I don't understand that. The process has no exit code before it has
ended,
> so how would you expect to be able to get one?

Well the exit code that was used for the exit function call is stored
in memory somewhere. The exit function doesn't just immediately
terminate the program. A whole bunch of other stuff happens first,
i.e. resources freed, exit handlers called, etc.
That variable has to be stored somewhere so that you end up with value
1 when the process finally ends.
 




 10 Posts in Topic:
Catching exit code before program termination
titanandrews <titanand  2008-05-08 09:05:09 
Re: Catching exit code before program termination
Sam <sam@[EMAIL PROTEC  2008-05-08 11:34:36 
Re: Catching exit code before program termination
Sam <sam@[EMAIL PROTEC  2008-05-08 11:44:26 
Re: Catching exit code before program termination
Martin York <Martin.Yo  2008-05-08 11:30:47 
Re: Catching exit code before program termination
titanandrews <titanand  2008-05-08 12:47:53 
Re: Catching exit code before program termination
Rolf Magnus <ramagnus@  2008-05-08 23:28:02 
Re: Catching exit code before program termination
Joe Greer <jgreer@[EMA  2008-05-08 22:15:22 
Re: Catching exit code before program termination
titanandrews <titanand  2008-05-08 17:36:08 
Re: Catching exit code before program termination
Jerry Coffin <jcoffin@  2008-05-10 22:29:34 
Re: Catching exit code before program termination
kasthurirangan.balaji@[EM  2008-05-08 22:08:45 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu Jul 24 2:12:10 CDT 2008.