"Joachim Schmitz" <> writes:
> Richard wrote:
>> "Joachim Schmitz" <> writes:
>>
>>> Richard Tobin wrote:
>>>> In article <fqrpdo$uur$>,
>>>> Joachim Schmitz <> wrote:
>>>>
>>>>>>> When i use system() it always get return code 11 and the command
>>>>>>> is not executed regardless of the command used. Does anyone know
>>>>>>> what is with it? Environment is Linux, glibc and gcc.
>>>>
>>>>>> That usually indicates a segmentation fault in the called command.
>>>>
>>>>> You may be confusing signal 11, SISSEGV, with exit(11)
>>>>
>>>> No. Under Linux, the return code from system() is the signal number
>>>> if the program dies from a signal. If the command exited with
>>>> status 11, system() would return 11*256.
>>> Right, sorry, didn't read the man-page properly
>>>
>>> int status = system("whatever")
>>> if ( status = -1)
>>> perror("system()");
>>
>> You might want to use a debugger on your code and examine the
>> condition above very closely. Hint : keep an eye on "status".
> No debugger needed, it should be status == -1.
There are many people in CLC who think debuggers are evil. Having worked
on numerous huge multi team projects I think their view is distorted to
say the least. We are not all Linus Torwalds.
I run ALL my code through a debugger watching the locals and parameter
panels as I step through for any unexpected blinks to occur.
This would have immediately alerted you to the change in status.
So my point was more "use a debugger" than "in this case". Well, it was
intended to be.
Littering code with printfs in amateurish at best unless there is no
good HW debugger for your platform.
Read this and good luck!
http://heather.cs.ucdavis.edu/~matlo....html#tth_sEc2