Modifying the Set of Blocked Signals

The sigprocmask( ) system call allows processes to modify the set of blocked signals; it applies only to regular (non-real-time) signals. The corresponding sys_sigprocmask( ) service routine acts on three parameters:

oset

Pointer in the process address space to a bit array where the previous bit mask must be stored

Pointer in the process address space to the bit array containing the new bit mask how

Flag that may have one of the following values:

SIG_BLOCK

The *set bit mask array specifies the signals that must be added to the bit mask array of blocked signals.

SIG_UNBLOCK

The *set bit mask array specifies the signals that must be removed from the bit mask array of blocked signals.

SIG_SETMASK

The *set bit mask array specifies the new bit mask array of blocked signals.

The function invokes copy_from_user( ) to copy the value pointed to by the set parameter into the new_set local variable and copies the bit mask array of standard blocked signals of current into the old_set local variable. It then acts as the how flag specifies on these two variables:

if (copy from user(&new set, set, sizeof(*set)))

return -EFAULT; new_set &= ~(sigmask(SIGKILL)|sigmask(SIGSTOP)); spin lock irq(&current->sigmask lock); old set = current->blocked.sig[0]; if (how == SIG_BLOCK)

sigaddsetmask(&current->blocked, new set); else if (how == SIG_UNBLOCK)

sigdelsetmask(&current->blocked, new set); else if (how == SIG_SETMASK)

current->blocked.sig[0] = new set;

else return -EINVAL; recalc sigpending(current); spin unlock irq(&current->sigmask lock); if (oset) {

if (copy to user(oset, &old set, sizeof(*oset))) return -EFAULT;

return 0;

Was this article helpful?

0 0

Post a comment