Error Codes Linux
Contents |
Aug 2004 on RedHat 7.3 #define EPERM 1 /* Operation not permitted */ #define ENOENT 2 /* No such file or directory */ #define ESRCH 3 /* No such process */ errno linux #define EINTR 4 /* Interrupted system call */ #define EIO 5 /* I/O linux errno list error */ #define ENXIO 6 /* No such device or address */ #define E2BIG 7 /* Arg list too long */ errno values linux #define ENOEXEC 8 /* Exec format error */ #define EBADF 9 /* Bad file number */ #define ECHILD 10 /* No child processes */ #define EAGAIN 11 /* Try again */ #define ENOMEM 12 linux exit codes /* Out of memory */ #define EACCES 13 /* Permission denied */ #define EFAULT 14 /* Bad address */ #define ENOTBLK 15 /* Block device required */ #define EBUSY 16 /* Device or resource busy */ #define EEXIST 17 /* File exists */ #define EXDEV 18 /* Cross-device link */ #define ENODEV 19 /* No such device */ #define ENOTDIR 20 /* Not a directory */ #define EISDIR 21
Linux Error Numbers
/* Is a directory */ #define EINVAL 22 /* Invalid argument */ #define ENFILE 23 /* File table overflow */ #define EMFILE 24 /* Too many open files */ #define ENOTTY 25 /* Not a typewriter */ #define ETXTBSY 26 /* Text file busy */ #define EFBIG 27 /* File too large */ #define ENOSPC 28 /* No space left on device */ #define ESPIPE 29 /* Illegal seek */ #define EROFS 30 /* Read-only file system */ #define EMLINK 31 /* Too many links */ #define EPIPE 32 /* Broken pipe */ #define EDOM 33 /* Math argument out of domain of func */ #define ERANGE 34 /* Math result not representable */ #define EDEADLK 35 /* Resource deadlock would occur */ #define ENAMETOOLONG 36 /* File name too long */ #define ENOLCK 37 /* No record locks available */ #define ENOSYS 38 /* Function not implemented */ #define ENOTEMPTY 39 /* Directory not empty */ #define ELOOP 40 /* Too many symbolic links encountered */ #define EWOULDBLOCK EAGAIN /* Operation would block */ #define ENOMSG 42 /* No message of desired type */ #define EIDRM 43 /* Identifier removed */ #define ECHRNG 44 /* Channel number out of range */ #define EL2NSYN
DESCRIPTION top The
Linux Kernel Error Codes
in the event of an error to indicate what went wrong. Its value is unix error codes significant only when the return value of the call indicated an error (i.e., -1 from most system calls; -1 or NULL linux error codes 127 from most library functions); a function that succeeds is allowed to change errno. Valid error numbers are all nonzero; errno is never set to zero by any system call or library function. For some system http://www-numi.fnal.gov/offline_software/srt_public_context/WebDocs/Errors/unix_system_errors.html calls and library functions (e.g., getpriority(2)), -1 is a valid return on success. In such cases, a successful return can be distinguished from an error return by setting errno to zero before the call, and then, if the call returns a status that indicates that an error may have occurred, checking to see if errno has a nonzero value. errno is defined by the ISO C standard to be http://man7.org/linux/man-pages/man3/errno.3.html a modifiable lvalue of type int, and must not be explicitly declared; errno may be a macro. errno is thread-local; setting it in one thread does not affect its value in any other thread. All the error names specified by POSIX.1 must have distinct values, with the exception of EAGAIN and EWOULDBLOCK, which may be the same. Below is a list of the symbolic error names that are defined on Linux. Some of these are marked POSIX.1, indicating that the name is defined by POSIX.1-2001, or C99, indicating that the name is defined by C99. E2BIG Argument list too long (POSIX.1) EACCES Permission denied (POSIX.1) EADDRINUSE Address already in use (POSIX.1) EADDRNOTAVAIL Address not available (POSIX.1) EAFNOSUPPORT Address family not supported (POSIX.1) EAGAIN Resource temporarily unavailable (may be the same value as EWOULDBLOCK) (POSIX.1) EALREADY Connection already in progress (POSIX.1) EBADE Invalid exchange EBADF Bad file descriptor (POSIX.1) EBADFD File descriptor in bad state EBADMSG Bad message (POSIX.1) EBADR Invalid request descriptor EBADRQC Invalid request code EBADSLT Invalid slot EBUSY Device or resource busy (POSIX.1) ECANCELED Operation canceled (POSIX.1) ECHILD No child processes (POSIX.1) ECHRNG Channel number out of range ECOMM Communication error on send ECONNABORTED Connection aborted (POSIX.1) ECONNREFUSED Connection refused (POSIX.1) ECONNRESET Connection reset (P
message ... (errno: #) message ... (Errcode: #) You can find out what the error code means by examining the documentation for your system or https://linux.die.net/man/1/perror by using the perror utility. perror prints a description for a system error code or for a storage engine (table handler) error code. Invoke perror like this: shell> perror [options] errorcode ... http://stackoverflow.com/questions/27096985/getting-error-code-when-creating-a-socket-in-linux Example: shell> perror 13 64 OS error code 13: Permission denied OS error code 64: Machine is not on the network To obtain the error message for a MySQL Cluster error code, error codes invoke perror with the --ndb option: shell> perror --ndb errorcode Note that the meaning of system error messages may be dependent on your operating system. A given error code may mean different things on different operating systems. perror supports the following options. • --help, --info, -I, -? Display a help message and exit. • --ndb Print the error message for a MySQL Cluster error error codes linux code. • --silent, -s Silent mode. Print only the error message. • --verbose, -v Verbose mode. Print error code and message. This is the default behavior. • --version, -V Display version information and exit. Copyright Copyright © 1997, 2012, Oracle and/or its affiliates. All rights reserved. This documentation is free software; you can redistribute it and/or modify it only under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This documentation is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with the program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or see http://www.gnu.org/licenses/. See Also For more information, please refer to the MySQL Reference Manual, which may already be installed locally and which is also available online at http://dev.mysql.com/doc/. Author Oracle Corporation (http://dev.mysql.com/). Referenced By mysqld(1)
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Getting error code when creating a socket in Linux up vote 0 down vote favorite I'm doing some socket programming in Linux and am wondering how to get the error code when the function socket(...); fails. for example for the "getaddrinfo" function i can do this: //Resolve the server address and port result = (struct addrinfo *) calloc(1, sizeof(struct addrinfo)); iResult = getaddrinfo("google.com", DEFAULT_PORT, &hints, &result); if (iResult != 0){ printf("%d\n", iResult); fprintf(stderr, "getaddrinfo failed: %s\n", gai_strerror(iResult)); getchar(); exit(EXIT_FAILURE); } However I want to do a similar thing using socket(...) function. According to this: http://linux.die.net/man/2/socket the function returns -1 on failure, and sets errno to the appropriate error number. How do i access this "errno" though? 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 getchar(); exit(EXIT_FAILURE); } Please help. Thanks! yahya c linux sockets share|improve this question asked Nov 24 '14 at 2:23 Yahya Uddin 2,01911439 2 See errno(3) and strerror(3) manual pages. –Nikolai N Fetissov Nov 24 '14 at 2:28 2 DO NOT allocate memory for the addrinfo that you pass in the last parameter of getaddrinfo(). 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 Lebeau Nov 24 '14 at 6:29 add a comment| 2 Answers 2 active oldest votes up vote 2 down vote accepted errno is a thread-local global variable, defined in