Sign in to follow this  
Followers 0
suthers

Trapping a process exit code without runwait()

5 posts in this topic

Hi All,

I launch a child process that take a long time to exit. I wish to trap its exit code. Using RunWait() this is easy, but the script is haltes while it waits for the child process. Using Run() instead I can trap the StdOut & StdIn streams, but can't figure out a way to get the exit code.

Is there a way?

Shalom

Bill

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hi All,

I launch a child process that take a long time to exit. I wish to trap its exit code. Using RunWait() this is easy, but the script is haltes while it waits for the child process. Using Run() instead I can trap the StdOut & StdIn streams, but can't figure out a way to get the exit code.

Is there a way?

Shalom

Bill

There was a possible solution recently posted by a certain rakishly good-looking antarctic water fowl...

La chiam!

>_<

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

That rakishly good-looking antarctic water fowl knows his stuff :-) My concern is that the process may not exist for long enough to grab the handle. The child process I'm launching in a command-line FTP utility. If the host is not accessable it exits extremely rapidly. I have actually got a messy workaround operating. Basically I launch, using run(), a second AutoIT process, which then launches my utility via RunWait(). The second process captures the exit code & saves it to a file, then exits. When the main script detects the second has closed, it picks up the code from the file. I'm now looking at eliminating the tempfile by using STD streams to communicate between the two autoIT processes....but if your solution can grap the process handle in time it will be soooo much neater. If it works, how do I give credit to yourself and the author of the AutoITWrapper UDFs in my script?

Shalom

Bill

Share this post


Link to post
Share on other sites

It works a treat :-) Seems to grab the handle even for short duration processes. Now I can get StdErr and Exit code. Thank you!!!

Shalom

Bill

PS

I just discovered that FTP uploading functionality has been added to the std distribution from 3.3.1.0, so this whole effort to utilise a 3rd party FTP app may be moot.....

Arh well...it was a good exercise :-)

Share this post


Link to post
Share on other sites

Seems to grab the handle even for short duration processes.

Glad it worked for you. I ran a timer on the _ProcessGetHandle() function, and it returned in under 500us every time. So that's probably not something to worry about.

:D


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0