Getting a return code of 128 from ANSI C function - What does 128 mean?

S

Sam

In our C++ program, we are using the system call to
execute another C++ program synchronously. The program
executed by system runs without error and returns back a
0.

Under conditions we cannot determine, the system function
will return back a 128 even though the command executed
exited with a return code of 0.

I found in the Winerror.h, that 128 means

"128 : There are no child processes to wait for.
ERROR_WAIT_NO_CHILDREN "

Is the 128 returned back by the system function the same
value as the one referenced in Winerror.h?
 
J

Jochen Kalmbach

Sam said:
In our C++ program, we are using the system call to
execute another C++ program synchronously. The program
executed by system runs without error and returns back a
0.

Under conditions we cannot determine, the system function
will return back a 128 even though the command executed
exited with a return code of 0.

Which system function !???

Do you mean "system" !?
http://msdn.microsoft.com/library/en-us/vclib/html/_crt_system.2c_.
_wsystem.asp

Normally it should only return 0 or -1... and the real error is in "errno".
You can also look at the CRT-source to see what is called and what is
returned.

But generally I would suggest to use CreateProcess, to have full control
over the API.

--
Greetings
Jochen

Do you need a memory-leak finder ?
http://www.codeproject.com/useritems/leakfinder.asp
 
S

Sam

Thanks for the reply Jochen,

Yes, I am referring to the stdlib.h function system.

Here is what the MS Help page says about the return value
for their version of system

"...If command is NULL and the command interpreter is
found, the function returns a nonzero value. If the
command interpreter is not found, it returns 0 and sets
errno to ENOENT. If command is not NULL, system returns
the value that is returned by the command interpreter. It
returns the value 0 only if the command interpreter
returns the value 0. A return value of - 1 indicates an
error, and errno is set to one of the following
values: ..."

The second part where the command is not NULL applies to
us. For some reason, the programmer who originally wrote
this code is flagging the return value of system as an
error if it is greater than 8. However, as the help page
indicates, -1 normally indicates an error.

9 times out of 10, the retcode of the function is 0.
However, every 10 th time or so we get an error code 128
which causes or process to error out. Our management
wants to know what is 128 and what the solution is.

I guess what I am trying to get confirmation that 128
means "There are no child processes to wait for." which is
kind of a DUH type of ret code and can be ignored. After
all, if control is reverting back to the parent process,
the child process should be gone.

Let me know if you know the answer,

Thanks,

Sam
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top