pthread_kill Subroutine

Purpose

Sends a signal to the specified thread.

Library

Threads Library (libpthreads.a)

Syntax

#include <signal.h>

int pthread_kill (thread, signal)
pthread_t thread;
int signal;

Description

The pthread_kill subroutine sends the signal signal to the thread thread. It acts with threads like the kill subroutine with single-threaded processes.

If the receiving thread has blocked delivery of the signal, the signal remains pending on the thread until the thread unblocks delivery of the signal or the action associated with the signal is set to ignore the signal.

Note: The pthread.h header file must be the first included file of each source file using the threads library. Otherwise, the -D_THREAD_SAFE compilation flag should be used, or the cc_r compiler used. In this case, the flag is automatically set.

Parameters

Item Description
thread Specifies the target thread for the signal.
signal Specifies the signal to be delivered. If the signal value is 0, error checking is performed, but no signal is delivered.

Return Values

Upon successful completion, the function returns a value of zero. Otherwise the function returns an error number. If the pthread_kill function fails, no signal is sent.

Error Codes

The pthread_kill function will fail if:

Item Description
ESRCH No thread could be found corresponding to that specified by the given thread ID.
EINVAL The value of the signal parameter is an invalid or unsupported signal number.

The pthread_kill function will not return an error code of EINTR.