Signals - kevshouse/The-Under_C_World GitHub Wiki

My musing on signals and inter-process communication

In C programming, signals are asynchronous messages that inform a program of an event. Asynchronos describes the relationship between two or more objects or events that interact within the same system, but do not occur at predetermined intervals or necessarily rely on each other's existence to function. These events are not coordinated with each other, so they can occur simultaneously, but do not have to because they have their own separate agenda. With that in mind, one may use signals to provide communication between a program ans an OS, or between processes.

Signals are typically used for: Reporting exceptional behavior, such as divide by zero. Reporting asynchronous events, e.g. keypress like cntrl+C. Prompting action base on an event. Terminating a program.

Signal Propagation:

cntrl-> OS -> process (in context)

process--(signal)-->process

e.g.

process--(sigkill)-->process

Signal Handling: Defined in the C standard library... psignal() returns a message describing a signal.

Examples:

SIGINT:

Sent after a cntrl+C event to interrupt a process.

SIGKILL:

Terminates a process immediately.

SIGALRM:

Sent after interval timeout of alarmd() expires.

SIGCHLD:

Child to parent signal sent on child termination.