Exec Exit Code Meaning for 11

exec Exit Code Meaning for 11

Code 11 is a "segmentation fault": A segmentation fault (also segfault) is caused by a program when it tries to allocate data in a piece of memory that is not assigned to the program. It indicates a program error and usually (if not always) crashes the program. In your case, the segfault probably is caused by phantomjs, which indicates perhaps an old or beta version.

getRuntime().exec() return exit code 11

To fix it I changed the command to be:

hive -hiveconf mapred.map.child.java.opts=-Xmx2048M -hiveconf mapred.job.shuffle.input.buffer.percent=0.30 -hiveconf io.sort.factor=25 -hiveconf io.sort.mb=256 -hiveconf mapred.job.reuse.jvm.num.tasks=500 -hiveconf mapred.job.priority=VERY_LOW -f filename;

As you can see I changed the -e query to -f filename.

Are there any standard exit status codes in Linux?

8 bits of the return code and 8 bits of the number of the killing signal are mixed into a single value on the return from wait(2) & co..

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <signal.h>

int main() {
int status;

pid_t child = fork();
if (child <= 0)
exit(42);
waitpid(child, &status, 0);
if (WIFEXITED(status))
printf("first child exited with %u\n", WEXITSTATUS(status));
/* prints: "first child exited with 42" */

child = fork();
if (child <= 0)
kill(getpid(), SIGSEGV);
waitpid(child, &status, 0);
if (WIFSIGNALED(status))
printf("second child died with %u\n", WTERMSIG(status));
/* prints: "second child died with 11" */
}

How are you determining the exit status? Traditionally, the shell only stores an 8-bit return code, but sets the high bit if the process was abnormally terminated.


$ sh -c 'exit 42'; echo $?
42
$ sh -c 'kill -SEGV $$'; echo $?
Segmentation fault
139
$ expr 139 - 128
11

If you're seeing anything other than this, then the program probably has a SIGSEGV signal handler which then calls exit normally, so it isn't actually getting killed by the signal. (Programs can chose to handle any signals aside from SIGKILL and SIGSTOP.)

How to debug exit status 1 error when running exec.Command in Golang

The solution is to use the Stderr property of the Command object. This can be done like this:

cmd := exec.Command("find", "/", "-maxdepth", "1", "-exec", "wc", "-c", "{}", "\\")
var out bytes.Buffer
var stderr bytes.Buffer
cmd.Stdout = &out
cmd.Stderr = &stderr
err := cmd.Run()
if err != nil {
fmt.Println(fmt.Sprint(err) + ": " + stderr.String())
return
}
fmt.Println("Result: " + out.String())

Running the above code, would make it clear what the issue is:

exit status 1: find: -exec: no terminating ";" or "+"

Edit:

In the code above, we expect that in case of error, the messages will be printed to stderr and the command will return a non-zero error code. This is more or less standard.

However, as mentioned below by @snorberhuis, some commands print the errors to stdout. Other commands might print to stderr but return an error code of 0 (in which case err will be nil). And having messages in stderr doesn't necessarily mean there's an error (ffmpeg tools do this a lot).

So basically you might need to tweak the code above to accommodate the commands you expect.

Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)

The SIGSEGV signal indicates a "segmentation violation" or a "segfault". More or less, this equates to a read or write of a memory address that's not mapped in the process.

This indicates a bug in your program. In a Python program, this is either a bug in the interpreter or in an extension module being used (and the latter is the most common cause).

To fix the problem, you have several options. One option is to produce a minimal, self-contained, complete example which replicates the problem and then submit it as a bug report to the maintainers of the extension module it uses.

Another option is to try to track down the cause yourself. gdb is a valuable tool in such an endeavor, as is a debug build of Python and all of the extension modules in use.

After you have gdb installed, you can use it to run your Python program:

gdb --args python <more args if you want>

And then use gdb commands to track down the problem. If you use run then your program will run until it would have crashed and you will have a chance to inspect the state using other gdb commands.

Get exit code - Go

It's easy to determine if the exit code was 0 or something else. In the first case, cmd.Wait() will return nil (unless there is another error while setting up the pipes).

Unfortunately, there is no platform independent way to get the exit code in the error case. That's also the reason why it isn't part of the API. The following snippet will work with Linux, but I haven't tested it on other platforms:

package main

import "os/exec"
import "log"
import "syscall"

func main() {
cmd := exec.Command("git", "blub")

if err := cmd.Start(); err != nil {
log.Fatalf("cmd.Start: %v", err)
}

if err := cmd.Wait(); err != nil {
if exiterr, ok := err.(*exec.ExitError); ok {
log.Printf("Exit Status: %d", exiterr.ExitCode())
} else {
log.Fatalf("cmd.Wait: %v", err)
}
}
}

Just follow the api docs to find out more :)

127 Return code from $?

Value 127 is returned by /bin/sh when the given command is not found within your PATH system variable and it is not a built-in shell command. In other words, the system doesn't understand your command, because it doesn't know where to find the binary you're trying to call.

What does Process finished with exit code 1 mean?

0 and 1 are exit codes, and they are not necessarily python specific, in fact they are very common.

exit code (0) means an exit without errors or issues.

exit code (1) means there was some issue / problem which caused the program to exit.

The effect of each of these codes can vary between operating systems, but with Python should be fairly consistent.

Unable to find out what return code of -11 means

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.



Related Topics



Leave a reply



Submit