SIGBUS
Encyclopedia : S : SI : SIG : SIGBUS
On POSIX compliant platforms, SIGBUS is the symbolic name for the signal thrown by computer programs causing a bus error. SIGBUS is a symbolic constant defined in signal.h. Symbolic signal names are used as signal numbers can vary across platforms.
Etymology
SIG- is a common prefix for signal names. BUS refers to the data bus in the context of a bus error.Usage
Computer programs may throw SIGBUS for improper memory handling:
- invalid address alignment
- the program has attempted to read or write data that does not fit the CPU's memory alignment rules.
- non-existent physical address
- this is equivalent to a segmentation fault, but for a physical address rather than a virtual address.
- object-specific hardware error
- this is far less common, however it is present in Solaris, when virtual memory pages have disappeared (e.g. accessing an mmaped file which has been truncated. [bus error.
The operating system may inform the application of the nature of the error using the signal stack, which developers can use to debug their programs or handle errors.
The default action on being sent SIGBUS is an abnormal termination, this will end the process but may generate a core file to aid debugging, or other platform dependent action.
SIGBUS can be handled (caught), that is, applications can request what action they want to occur. Examples of such action might be ignoring it, calling a function, or restoring the default action. In some circumstances, ignoring SIGBUS can result in undefined behaviour.
An example of an application that might handle SIGBUS is a debugger, which might check the signal stack and inform the developer of what happened, and where his program terminated.
SIGBUS is usually generated by the Operating System, however users with appropriate permissions can use the
kill()system call, or kill command (userland program, or sometimes a shell builtin) to send the signal to a process at will.POSIX Signals SIGABRT | SIGALRM | SIGFPE | SIGHUP | SIGILL | SIGINT | SIGKILL | SIGPIPE | SIGQUIT | SIGSEGV | SIGTERM | SIGUSR1 | SIGUSR2 | SIGCHLD | SIGCONT | SIGSTOP | SIGTSTP | SIGTTIN | SIGTTOU | SIGBUS | SIGPOLL | SIGPROF | SIGSYS | SIGTRAP | SIGURG | SIGVTALRM | SIGXCPU | SIGXFSZ | Realtime Signals are user definable—SIGRTMIN+n through SIGRTMAX. Common non-POSIX signals and synonyms SIGIOT | SIGEMT | SIGSTKFLT | SIGIO | SIGCLD | SIGPWR (SIGINFO) | SIGLOST | SIGWINCH | SIGUNUSED
From Wikipedia, the Free Encyclopedia. Original article here. Support Wikipedia by contributing or donating.
All text is available under the terms of the GNU Free Documentation License See Wikipedia Copyrights for details.
