thr_kill(2)

thr_kill2

Send signal to thread

Usage

#include <sys/thr.h>

int

thr_kill(long id, int sig);

int

thr_kill2(pid_t pid, long id, int sig);

Library

Standard C Library (libc, -lc)

Overview

The thr_kill() and thr_kill2() system calls allow sending a signal, specified by the sig argument, to some threads in a process. For the thr_kill() function, signalled threads are always limited to the current process. For the thr_kill2() function, the pid argument specifies the process with threads to be signalled.

The id argument specifies which threads get the signal. If id is equal to -1, all threads in the specified process are signalled. Otherwise, only the thread with the thread identifier equal to the argument is signalled.

The sig argument defines the delivered signal. It must be a valid signal number or zero. In the latter case no signal is actually sent, and the call is used to verify the liveness of the thread.

The signal is delivered with siginfo si_code set to SI_LWP.

Return values

If successful, thr_kill() and thr_kill2() will return zero, otherwise -1 is returned, and errno is set to indicate the error.

Errors

The thr_kill() and thr_kill2() operations return the following errors:

[EINVAL]

The sig argument is not zero and does not specify valid signal.

[ESRCH]

The specified process or thread was not found.

Additionally, the thr_kill2() may return the following errors:

[EPERM]

The current process does not have sufficient privilege to check existence or send a signal to the specified process.

Releases

25 releases since FreeBSD 11.0-RELEASE; the text changed 12 times.

  1. 11.0
  2. 11.1
  3. 11.2
  4. 11.3
  5. 11.4
  6. 12.0
  7. 12.1
  8. 12.2
  9. 12.3
  10. 12.4
  11. 13.0–13.2
  12. 13.3–14.2
  13. 14.3–16.0

Standards

The thr_kill() and thr_kill2() system calls are non-standard and are used by the library “libthr” to implement IEEE Std 1003.1-2001 (“POSIX.1”) pthread(3) functionality.

History

The thr_kill() and thr_kill2() system calls first appeared in FreeBSD 5.2.

From base 16.0-CURRENT-20261027-61c70dc16a79 in FreeBSD 16.0-CURRENT (2026-10-27). Parsed by carta from the page's mdoc source.