471,595 Members | 2,043 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,595 software developers and data experts.

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

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?
Nov 16 '05 #1
2 5804
Sam wrote:
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...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
Nov 16 '05 #2
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

-----Original Message-----
Sam wrote:
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 isreturned.

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

--
Greetings
Jochen

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

Nov 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

242 posts views Thread by James Cameron | last post: by
29 posts views Thread by pmatos | last post: by
10 posts views Thread by LaEisem | last post: by
232 posts views Thread by robert maas, see http://tinyurl.com/uh3t | last post: by
41 posts views Thread by Jim | last post: by
185 posts views Thread by jacob navia | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by Anwar ali | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.