Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to find out what return code of -11 means

Tags:

python

c

linux

I am writing a tool which is written in python and C. The python script reads a configuration file, performs some validation makes several calls to the C program.

system: RHE 5.7, python: 2.7.6, gcc: 4.5.2

Some of the parameters to the called C program are the paths of input files. There is one case where the input file path is the same for several C program invocations. In this case only the first call succeeds, and the returncode from the python subprocess module is '-11'.

I am not sure how to progress this. For a start, I cannot find documentation indicating what '-11' might mean as an exit status. It does not appear to be in the 'standard' codes in /usr/include/sysexits.h. I am guessing that the code could also be interpreted as 0xf5 or 245, since exit codes are I believe really signed 8-bit values.

I have added debug to the start of the C program to print out the arguments it was called with, but nothing appears for the failed invocations. I can understand how the C might fail re-opening a file which was read on the previous invocation (perhaps), but the code doesn't even get that far!

So, where is the exit code coming from? Is it from the (bash) environment which the python subprocess module presumably uses to invoke the C program? Is it from the C runtime for the C program before it even reaches main?

I suppose I could progress this by moving the 'loop' down into the C, so that it only gets called once for each input file path, but that still does not explain this behaviour. Could someone please explain how I can determine the cause of this error? Thanks.

(FWIW) calling from python:

try:
  subprocess.check_call( args )
except subprocess.CalledProcessError as e:
  print e

Entry to the C:

printf( "\n--- swizzle\n\nargs:\n" );
for ( int i = 0; i < argc; i++ ) printf( "- %s\n", argv[ i ]);

Error output:

Command '[..]' returned non-zero exit status -11
like image 618
PatB Avatar asked Jun 10 '14 11:06

PatB


People also ask

What is the meaning of return code?

A return code (severity code), passed in register 15, which gives a global statement about the success or failure of the requested service, and. A reason code, returned in register 0, which informs the caller in detail about any failing condition.

What is the use of return code?

Use a return code in conjunction with its corresponding file status or reason code to determine the result of a call to the API, and identify the cause of a problem or failure if one arises. Success - for a Get Next or Get Previous function call there was no key change from the previous call.

How do you set return code from the Cobol program?

The RETURN-CODE special register can be used to pass a return code to the calling program or operating system when the current COBOL program ends. When a COBOL program ends: If control returns to the operating system, the value of the RETURN-CODE special register is passed to the operating system as a user return code.

What is return code in SAP?

Return Code. Background. The most prominent system field should be the return code sy-subrc. This indicates the successful execution of an ABAP statement or, if you are using classic exceptions, a procedure. A return code of 0 usually means that the execution was successful.


1 Answers

Return code -11 means "segmentation fault". A negative return code usually means that the process was terminated by a signal. Return code -11 means it was signal 11, which is SIGSEGV.

like image 101
sth Avatar answered Oct 13 '22 00:10

sth