---
name: "thr_suspend"
section: "2freebsd"
platform: "linux"
package: "freebsd-manpages"
version: "12.2-2"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/thr_suspend/2freebsd"
---

# thr\_suspend(2freebsd)

suspend the calling thread

## NAME

**thr\_suspend** – suspend the calling thread

## LIBRARY

Standard C Library (libc, -lc)

## SYNOPSIS

**#include \<sys/thr.h\>**

*int*\

**thr\_suspend**(*struct timespec \*timeout*);

## DESCRIPTION

This function is intended for implementing threading. Normal applications should use [pthread\_cond\_timedwait(3)](/pthread_cond_timedwait/3.md) together with [pthread\_cond\_broadcast(3)](/pthread_cond_broadcast/3.md) for typical safe suspension with cooperation of the thread being suspended, or [pthread\_suspend\_np(3)](/pthread_suspend_np/3.md) and [pthread\_resume\_np(3)](/pthread_resume_np/3.md) in some specific situations, instead.

The **thr\_suspend**() system call puts the calling thread in a suspended state, where it is not eligible for CPU time. This state is exited by another thread calling [thr\_wake(2)](/thr_wake/2.md), when the time interval specified by *timeout* has elapsed, or by the delivery of a signal to the suspended thread.

If the *timeout* argument is NULL, the suspended state can be only terminated by explicit **thr\_wake**() or signal.

If a wake from [thr\_wake(2)](/thr_wake/2.md) was delivered before the **thr\_suspend** call, the thread is not put into a suspended state. Instead, the call returns immediately without an error.

If a thread previously called [thr\_wake(2)](/thr_wake/2.md) with its own thread identifier, which resulted in setting the internal kernel flag to immediately abort interruptible sleeps with an EINTR error( see [thr\_wake(2)](/thr_wake/2.md)), the flag is cleared. As with [thr\_wake(2)](/thr_wake/2.md) called from another thread, the next **thr\_suspend** call does not result in suspension.

## RETURN VALUES

The **thr\_suspend()** function returns the value 0 if successful; otherwise the value -1 is returned and the global variable errno is set to indicate the error.

## ERRORS

The **thr\_suspend**() operation returns the following errors:

- \[EFAULT\]

  The memory pointed to by the *timeout* argument is not valid.

- \[ETIMEDOUT\]

  The specified timeout expired.

- \[ETIMEDOUT\]

  The *timeout* argument specified a zero time interval.

- \[EINTR\]

  The sleep was interrupted by a signal.

## SEE ALSO

[ps(1)](/ps/1.md), [thr\_wake(2)](/thr_wake/2.md), [pthread\_resume\_np(3)](/pthread_resume_np/3.md), [pthread\_suspend\_np(3)](/pthread_suspend_np/3.md)

## STANDARDS

The **thr\_suspend**() system call is non-standard.
