Program received signal SIGSEGV, Segmentation fault

If you are on Linux, try running valgrind. You just compile with -g (with gcc), and then run your program with valgrind in front: Unlike the GCC solutions, which tell you when the segfault occurs, valgrind usually tells you exactly when the first memory corruption occurs, so you can catch the problem much closer to its source. PS. It rhymes … Read more

What is the difference between SIGSTOP and SIGTSTP?

Both signals are designed to suspend a process which will be eventually resumed with SIGCONT. The main differences between them are: SIGSTOP is a signal sent programmatically (eg: kill -STOP pid ) while SIGTSTP (for signal – terminal stop) may also be sent through the tty driver by a user typing on a keyboard, usually Control–Z. SIGSTOP cannot be ignored. SIGTSTP might be.

Program received signal SIGSEGV, Segmentation fault

If you are on Linux, try running valgrind. You just compile with -g (with gcc), and then run your program with valgrind in front: Unlike the GCC solutions, which tell you when the segfault occurs, valgrind usually tells you exactly when the first memory corruption occurs, so you can catch the problem much closer to its source. PS. It rhymes … Read more

How to trigger SIGUSR1 and SIGUSR2?

They are user-defined signals, so they aren’t triggered by any particular action. You can explicitly send them programmatically: where pid is the process id of the receiving process. At the receiving end, you can register a signal handler for them:

What does WEXITSTATUS(status) return?

WEXITSTATUS(stat_val) is a macro (so in fact it does not “return” something, but “evaluates” to something). For how it works you might like to look it up in the headers (which should be #included via <sys/wait.h>) that come with the C-compiler you use. The implementation of this macro might differ from one C-implementation to the other. Please note, … Read more