sys_rt_sigaction  [kernel/signal.c]


Used to change or retrieve the action taken by a process on receipt of a specific "realtime" signal.

Arguments

eax 174
ebx Specifies the signal and can be any valid signal except SIGKILL and SIGSTOP.
ecx Pointer to a properly initialized old_sigaction structure which specifies the new action for the signal (this argument may be 0):
struc old_sigaction
{
.sa_handler:  ;rd 1
.sa_sigaction rd 1
.sa_mask      rd 1
.sa_flags     rd 1
.sa_restorer  rd 1
}

old_sigaction members:

sa_handler
Specifies the action to be associated with ebx and may be SIG_DFL for the default action, SIG_IGN to ignore this signal, or a pointer to a signal handling function (see SA_SIGINFO below). This function receives the signal number as its only argument.
sa_mask
Gives a mask of signals which should be blocked during execution of the signal handler. In addition, the signal which triggered the handler will be blocked, unless the SA_NODEFER flag is used.
sa_flags
Specifies a set of flags which modify the behavior of the signal handling process:
SA_ONSTACK Call the signal handler on an alternate signal stack provided by sys_sigaltstack. If an alternate stack is not available, the default stack will be used.
SA_RESTART Provide behaviour compatible with BSD signal semantics by making certain system calls restartable across signals.
SA_NOCLDSTOP If ebx is SIGCHLD, do not receive notification when child processes stop (i.e., when they receive one of SIGSTOP, SIGTSTP, SIGTTIN or SIGTTOU) or resume (i.e., they receive SIGCONT).
SA_RESETHAND Restore the signal action to the default state once the signal handler has been called. SA_ONESHOT is an obsolete, non-standard synonym for this flag.
SA_NOCLDWAIT If ebx is SIGCHLD, do not transform children into zombies when they terminate. See also sys_waitpid.
SA_NODEFER Do not prevent the signal from being received from within its own signal handler. SA_NOMASK is an obsolete, non-standard synonym for this flag.
SA_SIGINFO If this flag is specified, then sa_sigaction (instead of sa_handler) specifies the signal-handling function for ebx. This function receives the signal number as its first argument, a pointer to a siginfo structure as its second argument and a pointer to a ucontext as its third argument.

siginfo defined as follows:
struc siginfo
{
.si_signo   rd 1
.si_errno   rd 1
.si_code    rd 1
._kill:     ;kill
._timer:    ;timer
.__rt:      ;_rt
._sigchld:  ;sigchld
._sigfault: ;sigfault
._sigpoll:  ;sigpoll
._pad       rd 29
}
Where kill, timer, _rt, sigchld, sigfault, and sigpoll defined as follows:

struc kill
{
._pid rd 1
._uid rd 1
}

struc timer
{
._tid         rd 1
._overrun     rd 1
.sival_int:   ;rd 1
.sival_ptr    rd 1
._sys_private rd 1
}

struc _rt
{
._pid       rd 1
._uid       rd 1
.sival_int: ;rd 1
.sival_ptr  rd 1
}

struc sigchld
{
._pid    rd 1
._uid    rd 1
._status rd 1
._utime  rd 1
._stime  rd 1
}

struc sigfault
{
._addr rd 1
}

struc sigpoll
{
._band rd 1
._fd   rd 1
}


ucontext defined as follows:

struc ucontext
{
.uc_flags    rd 1
.uc_link     rd 1
.uc_stack    sigaltstack
.uc_mcontext sigcontext
.uc_sigmask  sigset
}

Where sigaltstack, sigcontext, and sigset are defined as follows:

struc sigaltstack
{
.ss_sp    rd 1
.ss_flags rd 1
.ss_size  rd 1
}

struc sigset
{
.sig rd 2
}

struc sigcontext
{
.gs            rw 1
.__gsh         rw 1
.fs            rw 1
.__fsh         rw 1
.es            rw 1
.__esh         rw 1
.ds            rw 1
.__dsh         rw 1
.edi           rd 1
.esi           rd 1
.ebp           rd 1
.esp           rd 1
.ebx           rd 1
.edx           rd 1
.ecx           rd 1
.eax           rd 1
.trapno        rd 1
.err           rd 1
.eip           rd 1
.cs            rw 1
.__csh         rw 1
.eflags        rd 1
.esp_at_signal rd 1
.ss            rw 1
.__ssh         rw 1
.fpstate       rd 1
.oldmask       rd 1
.cr2           rd 1
}

sa_restorer
This element is obsolete and should not be used.
edx Pointer to an old_sigaction structure where the previous action will be saved (this argument may be 0).
esi Size of the sigset_t (see include/asm-i386/signal.h).

Return values

If the system call succeeds the return value is 0.
If the system call fails the return value is one of the following errno values:

-EFAULT ecx or edx points to memory which is not a valid part of the process address space.
-EINVAL An invalid signal was specified. This will also be generated if an attempt is made to change the action for SIGKILL or SIGSTOP, which cannot be caught or ignored.

Remarks

In kernels up to and including 2.6.13, specifying SA_NODEFER in sa_flags preventing not only the delivered signal from being masked during execution of the handler, but also the signals specified in sa_mask. This bug is was fixed in kernel 2.6.14.

According to POSIX, the behaviour of a process is undefined after it ignores a SIGFPE, SIGILL, or SIGSEGV signal that was not generated by kill or raise. Integer division by zero has undefined result. On some architectures it will generate a SIGFPE signal. (Also dividing the most negative integer by -1 may generate SIGFPE.) Ignoring this signal might lead to an endless loop.

POSIX.1-1990 disallowed setting the action for SIGCHLD to SIG_IGN. POSIX.1-2001 allows this possibility, so that ignoring SIGCHLD can be used to prevent the creation of zombies (see sys_wait*). Nevertheless, the historical BSD and System V behaviours for ignoring SIGCHLD differ, so that the only completely portable method of ensuring that terminated children do not become zombies is to catch the SIGCHLD signal and perform a sys_wait or similar.

It is not possible to block SIGKILL or SIGSTOP (by specifying them in sa_mask). Attempts to do so are silently ignored.

Compatibility

n/a