Jump to content
  • Advertisement
Sign in to follow this  
discodowney

CreateProcess (C++)

This topic is 2354 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

So im working on making an automated test for some code. There is an executable run from the command line called "cmdLineProc".

Im making my test programs in C++ (not using Python or that cos theres an API we use that speeds these tests up).
The command line arguments are made in the test as strings and passed to a function that uses CreateProcess to run cmdLineProc..
This works fine. I can call cmdLineProc and it works and the tests pass. But only when theres not an error returned.

When testing I obv need to check that things are failing when they are supposed to as well. in these cases cmdLineProc returns an error value.

So if i run cmdLineProc on the command line with parameters that will make it fail, i get a message saying "Error, Failed: -3" where -3 is an error code.
But when i run this through the C++ test using CreateProcess I get a problem. The CreateProcess just fails and returns -1, the code to say it failed. It gives no indication of why it failed.
I use GetExitCodeProcess to get the termination status of the cmdLineProc.

Anyone know if its possible to get the error value from cmdLineProc returned back using this method? If not does anyone know how i might go about implementing this?

Cheers.

Share this post


Link to post
Share on other sites
Advertisement
Assuming you're not doing something like returning -1 from main in cmdLineProc, GetExitCodeProcess already does give you the return code.

Share this post


Link to post
Share on other sites

The CreateProcess just fails and returns -1, the code to say it failed.

Have you done the GetLastError() dance? If you put "$err,hr" in a Visual C++ watch and step over the call to CreateProcess(), that's often easier.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!