Home > Error Codes > Linux Error Codes

Linux Error Codes

Contents

there are dark corners in the Bourne shell, and people use all of them.

--Chet Ramey

The exit command terminates a script, Macro: int EIO Input/output error; usually used for physical read or write errors. exit / exit status

#!/bin/bash echo hello echo $? # Exit status 0 returned because command executed successfully. It will allocate the addrinfo for you, which you pass to freeaddrinfo() to free it: result = NULL; iResult = getaddrinfo(..., &result); if (iResult == 0) { ...; freeaddrinfo(result); } –Remy navigate to this website

For example, if you try to delete a file that is the root of a currently mounted filesystem, you get this error. Macro: int EISDIR File is a directory; you cannot open a directory for writing, or create or remove hard links to it. It may be anticipated that the range of unallotted exit codes will be further restricted in the future. Macro: int ESTALE Stale file handle. http://www.thegeekstuff.com/2010/10/linux-error-codes

Linux Errno Example

Macro: int EDEADLK Deadlock avoided; allocating a system resource would have resulted in a deadlock situation. Since exit code 1 signifies so many possible errors, it is not particularly useful in debugging.

There has been an attempt to systematize exit status numbers (see /usr/include/sysexits.h

Macro: int ENOTCONN The socket is not connected to anything. Macro: int EINTR Interrupted function call; an asynchronous signal occurred and prevented completion of the call. Macro: int EREMOTE An attempt was made to NFS-mount a remote file system with a file name that already specifies an NFS-mounted file. (This is an error on some operating systems, Errno.h Windows In that case, the shell will interpret the variable as empty and the cd succeed, but it will change directories to the user's home directory, so beware!

On GNU/Hurd systems, this error never happens; you get a signal instead. Posix Error Codes Such shortages are usually fairly serious and affect the whole system, so usually an interactive program should report the error to the user and return to its command loop. The author of this document will not do fixups on the scripting examples to conform to the changing standard. his explanation asked 5 years ago viewed 3909 times active 4 years ago Linked 1 bash if statement behaviour question Related 7What is the difference between a Library call and a System call

Macro: int ECONNABORTED A network connection was aborted locally. Errno.h In C Macro: int ENETDOWN A socket operation failed because the network was down. Macro: int EHOSTUNREACH The remote host for a requested network connection is not reachable. Macro: int ETIMEDOUT A socket operation with a specified timeout received no response during the timeout period.

Posix Error Codes

Only then does rm get executed; otherwise an error message is output and the program exits with a code of 1, indicating that an error has occurred. http://tldp.org/LDP/abs/html/exitcodes.html Aborting" rm * If an exit is not required in case of error, then you can even do this: # Another way to do it if exiting is not desired cd Linux Errno Example Macro: int ENODEV The wrong type of device was given to a function that expects a particular sort of device. Linux Errno To String But what happens if the directory named in $some_directory doesn't exist?

Unix & Linux Stack Exchange works best with JavaScript enabled useful reference Some of these error codes can’t occur on GNU systems, but they can occur using the GNU C Library on other systems. Shotts, Jr. Macro: int ELOOP Too many levels of symbolic links were encountered in looking up a file name. Errno.h Linux Kernel

Thus, your program will never actually see EPIPE unless it has handled or blocked SIGPIPE. share|improve this answer answered Feb 28 '11 at 7:09 Keith 5,0911521 I did not unmount the card before removing it. Perhaps I'll write a Python script. ;-) –Keith Feb 28 '11 at 7:34 @Keith: Some OSes make you think you don't need to unmount cleanly, and turn off write http://softacoustik.com/error-codes/linux-io-error-codes.php ENOEXEC Exec format error (POSIX.1) ENOKEY Required key not available ENOLCK No locks available (POSIX.1) ENOLINK Link has been severed (POSIX.1) ENOMEDIUM No medium found ENOMEM Not enough space (POSIX.1) ENOMSG

environment variable. $? Efault This error is never generated by GNU/Hurd systems, but it can result from an operation to an NFS server running another operating system. See Socket Addresses.

See Limits on Resources, for details on the RLIMIT_NPROC limit.

It can also return a value, which is available to the script's parent process.

Every command returns an exit status (sometimes referred to as a return status

Macro: int EACCES Permission denied; the file permissions do not allow the attempted operation. For example, exit 3809 gives an exit code of 225 (3809 % 256 = 225).

[2]An update of /usr/include/sysexits.h allocates previously unused exit Macro: int EGREGIOUS You did what? http://softacoustik.com/error-codes/linux-system-error-codes.php If the exit status is anything other than zero, then the program failed in some way.

This can mean that the device file was installed incorrectly, or that the physical device is missing or not correctly attached to the computer. This often indicates a cycle of symbolic links. Using them, we can see how the $? Every library function that returns this error code also generates a SIGPIPE signal; this signal terminates the program if not handled or blocked.

Macro: int ENETUNREACH A socket operation failed because the subnet containing the remote host was unreachable. Well-behaved UNIX commands, programs, and utilities return a 0 exit code upon successful completion, though there are some exceptions.

Likewise, functions within a script and the script Macro: int EALREADY An operation is already in progress on an object that has non-blocking mode selected. Macro: int EROFS An attempt was made to modify something on a read-only file system.

This condition is detected by the exec functions; see Executing a File. The second use, ${1:-"Unknown Error"} means that if parameter 1 ($1) is undefined, substitute the string "Unknown Error" in its place. Macro: int ERPCMISMATCH ??? Macro: int EHOSTDOWN The remote host for a requested network connection is down.

I agree that there may be an on-going query (status inquiry, etc.) from kernel (bus) side, and it did not find the medium and raised this error. –TheCottonSilk Feb 28 '11 Running the C-shell or tcsh may give different values in some cases.

Notes[1]Out of range exit values can result echo $? # Non-zero exit status returned -- command failed to execute. echo "exit status of \"true\" = $?" # 0 !

Macro: int ERANGE Range error; used by mathematical functions when the result value is not representable because of overflow or underflow. Macro: int EXDEV An attempt to make an improper link across file systems was detected. This is my code so far: int connectSocket = 0; connectSocket = socket(AF_INET, SOCK_STREAM, 0); printf("%d\n", connectSocket); if (connectSocket == -1){ printf("socket failed with error: %s\n", error_string); //TODO: HELP DECLARING error_string more hot questions question feed lang-c about us tour help blog chat data legal privacy policy work here advertising info mobile contact us feedback Technology Life / Arts Culture / Recreation

Can I stop this homebrewed Lucky Coin ability from being exploited? Macro: int EPROTOTYPE The socket type does not support the requested communications protocol.