Skip to main content

Signal

Functions

kill(pid_t pid, int signo)#

int kill (pid_t pid, int signo)

Type: int

Parameters:

  • pid_t pid
  • int signo

Details#

This function sends the signal signo to the process pid.

Returns:

Zero or -1 with errno (see Errno) set to:

  • EINVAL: signo is not a valid signal number
  • ESRCH: pid is not a valid process id

waitpid(pid_t pid, int *stat_loc, int options)#

pid_t waitpid (pid_t pid, int *stat_loc, int options)

Type: pid_t

Parameters:

  • pid_t pid
  • int * stat_loc
  • int options

wait(int *stat_loc)#

pid_t wait (int *stat_loc)

Type: pid_t

Parameters:

  • int * stat_loc

pthread_kill(pthread_t thread, int signo)#

int pthread_kill (pthread_t thread, int signo)

Type: int

Parameters:

  • pthread_t thread
  • int signo

Details#

This function sends the signal signo to thread. The handler is executed in the context of thread, but the signal effects the entire process. For example,

pthread_kill(8, SIGKILL);

will kill the process that holds thread 8. The exit handler will be executed on thread 8's stack.

Returns:

Zero or -1 with errno (see Errno) set to:

  • EINVAL: signo is not a valid signal number
  • ESRCH: pid is not a valid process id

sigqueue(pid_t pid, int signo, const union sigval value)#

int sigqueue (pid_t pid, int signo, const union sigval value)

Type: int

Parameters:

  • pid_t pid
  • int signo
  • const union sigval value

Details#

This function sends the signal signo to the process pid. The signal value is specified by value.

Returns:

Zero or -1 with errno (see Errno) set to:

  • EINVAL: signo is not a valid signal number
  • ESRCH: pid is not a valid process id

sigwait(const sigset_t set, int sig)#

int sigwait (const sigset_t *set, int *sig)

Type: int

Parameters:

  • const sigset_t * set
  • int * sig

Details#

This function checks to see if any signals in set are pending. If a signal is pending, it is cleared and the signal number is written to *sig, and the thread is not blocked.If no signals in set are pending, the thread is blocked until a signal becomes pending.The signals defined by set should be blocked when this function is called (see pthread_sigmask() and sigprocmask()).

Returns:

Zero or -1 with errno (see Errno) set to:

  • EINVAL: set contains an invalid or unsupported signal

sigtimedwait(const sigset_t set, siginfo_t info, const struct timespec *timeout)#

int sigtimedwait (const sigset_t *set, siginfo_t *info, const struct timespec *timeout)

Type: int

Parameters:

  • const sigset_t * set
  • siginfo_t * info
  • const struct timespec * timeout

Details#

This function checks to see if any signals in the set are pending. If a signal is pending, it is cleared and the signal information is written to info, and the function returns without blocking.If no signals in set are pending, the task is blocked until a signal becomes pending or until the timeout expires.

Returns:

Zero or -1 with errno (see Errno) set to:

  • EINVAL: set contains an invalid or unsupported signal
  • EAGAIN: timeout expired before any signals arrived
  • EINTR: a signal, not in set, was caught

sigwaitinfo(const sigset_t set, siginfo_t info)#

int sigwaitinfo (const sigset_t *set, siginfo_t *info)

Type: int

Parameters:

  • const sigset_t * set
  • siginfo_t * info

Details#

This function checks to see if any signals in set are pending. If a signal is pending, it is cleared and the signal info is written to info, and the function returns without blocking.If no signals in set are pending, the task is blocked until a signal becomes pending.

Returns:

Zero or -1 with errno (see Errno) set to:

  • EINVAL: set contains an invalid or unsupported signal
  • EINTR: a signal, not in set, was caught

signal(int sig, _sig_func_ptr func)#

_sig_func_ptr signal (int sig, _sig_func_ptr func)

Type: _sig_func_ptr

Parameters:

  • int sig
  • _sig_func_ptr func

Details#

This function sets the handler for sig to func.

Returns:

Zero or SIG_ERR with errno (see Errno) set to:

  • EINVAL: sig is not a valid signal or is a signal that cannot be caught.

sigaction(int sig, const struct sigaction act, struct sigaction oact)#

int sigaction (int sig, const struct sigaction *act, struct sigaction *oact)

Type: int

Parameters:

  • int sig
  • const struct sigaction * act
  • struct sigaction * oact

Details#

This function sets the action for sig to act. The previous action is written is oact if oact is not NULL. Using this function will override any handler previously set with signal().

Returns:

Zero or SIG_ERR with errno (see Errno) set to:

  • EINVAL: sig is not a valid signal or is a signal that cannot be caught.
  • EINTR: a signal, not in set, was caught

pthread_sigmask(int how, const sigset_t set, sigset_t oset)#

int pthread_sigmask (int how, const sigset_t *set, sigset_t *oset)

Type: int

Parameters:

  • int how
  • const sigset_t * set
  • sigset_t * oset

Details#

This function sets the signal mask for the current thread.

Returns:

Zero or SIG_ERR with errno (see Errno) set to:

  • EINVAL: how is not one of SIG_BLOCK, SIG_SETMASK, or SIG_UNBLOCK

sigprocmask(int how, const sigset_t set, sigset_t oset)#

int sigprocmask (int how, const sigset_t *set, sigset_t *oset)

Type: int

Parameters:

  • int how
  • const sigset_t * set
  • sigset_t * oset

Details#

This function sets the signal mask for the current thread. This function should only be called in single threaded applications.

Returns:

Zero or SIG_ERR with errno (see Errno) set to:

  • EINVAL: how is not one of SIG_BLOCK, SIG_SETMASK, or SIG_UNBLOCK

sigpending(sigset_t *set)#

int sigpending (sigset_t *set)

Type: int

Parameters:

  • sigset_t * set

Details#

This function writes the calling thread's current pending set to set. It then waits for a signal to arrive. If the action for the signal is to terminate, then this function never returns. If the action is to execute a signal catching function, the signal catching function is executed and the signal mask for the thread is restored before returning.

Returns:

-1 with errno set to EINTR otherwise never returns

sigsuspend(const sigset_t *sigmask)#

int sigsuspend (const sigset_t *sigmask)

Type: int

Parameters:

  • const sigset_t * sigmask