---
name: "F_GETOWN"
section: "2const"
platform: "linux"
package: "man-pages"
version: "6.19-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/F_GETSIG"
---

# F\_GETOWN(2const)

managing signals

Part of [F\_GETSIG(2const)](/F_GETSIG/2const.md).

## NAME

F\_GETOWN, F\_SETOWN, F\_GETOWN\_EX, F\_SETOWN\_EX, F\_GETSIG, F\_SETSIG - managing signals

## LIBRARY

Standard C library (*libc*, *-lc*)

## SYNOPSIS

```
#include <fcntl.h>
```

**int fcntl(int** *fd***, F\_GETOWN);** **int fcntl(int** *fd***, F\_SETOWN, int** *arg***);**

**#define \_GNU\_SOURCE** **#include \<fcntl.h\>**

**int fcntl(int** *fd***, F\_GETOWN\_EX, struct f\_owner\_ex \****arg***);** **int fcntl(int** *fd***, F\_SETOWN\_EX, const struct f\_owner\_ex \****arg***);** **int fcntl(int** *fd***, F\_GETSIG);** **int fcntl(int** *fd***, F\_SETSIG, int** *arg***);**

## DESCRIPTION

**F\_GETOWN**, **F\_SETOWN**, **F\_GETOWN\_EX**, **F\_SETOWN\_EX**, **F\_GETSIG**, and **F\_SETSIG** are used to manage I/O availability signals:

- **F\_GETOWN**

  Return (as the function result) the process ID or process group ID currently receiving **SIGIO** and **SIGURG** signals for events on file descriptor *fd*. Process IDs are returned as positive values; process group IDs are returned as negative values (but see BUGS below). *arg* is ignored.

- **F\_SETOWN**

  Set the process ID or process group ID that will receive **SIGIO** and **SIGURG** signals for events on the file descriptor *fd*. The target process or process group ID is specified in *arg*. A process ID is specified as a positive value; a process group ID is specified as a negative value. Most commonly, the calling process specifies itself as the owner (that is, *arg* is specified as [**getpid**(2)](/getpid/2.md)).

-

  As well as setting the file descriptor owner, one must also enable generation of signals on the file descriptor. This is done by using the [**F\_SETFL**(2const)](/F_SETFL/2const.md) operation to set the **O\_ASYNC** file status flag on the file descriptor. Subsequently, a **SIGIO** signal is sent whenever input or output becomes possible on the file descriptor. The **fcntl**() **F\_SETSIG** operation can be used to obtain delivery of a signal other than **SIGIO**.

-

  Sending a signal to the owner process (group) specified by **F\_SETOWN** is subject to the same permissions checks as are described for [**kill**(2)](/kill/2.md), where the sending process is the one that employs **F\_SETOWN** (but see BUGS below). If this permission check fails, then the signal is silently discarded. *Note*: The **F\_SETOWN** operation records the caller's credentials at the time of the **fcntl**() call, and it is these saved credentials that are used for the permission checks.

-

  If the file descriptor *fd* refers to a socket, **F\_SETOWN** also selects the recipient of **SIGURG** signals that are delivered when out-of-band data arrives on that socket. (**SIGURG** is sent in any situation where [**select**(2)](/select/2.md) would report the socket as having an "exceptional condition".)

-

  The following was true in Linux 2.6.x up to and including Linux 2.6.11:

  -

    If a nonzero value is given to **F\_SETSIG** in a multithreaded process running with a threading library that supports thread groups (e.g., NPTL), then a positive value given to **F\_SETOWN** has a different meaning: instead of being a process ID identifying a whole process, it is a thread ID identifying a specific thread within a process. Consequently, it may be necessary to pass **F\_SETOWN** the result of [**gettid**(2)](/gettid/2.md) instead of [**getpid**(2)](/getpid/2.md) to get sensible results when **F\_SETSIG** is used. (In current Linux threading implementations, a main thread's thread ID is the same as its process ID. This means that a single-threaded program can equally use [**gettid**(2)](/gettid/2.md) or [**getpid**(2)](/getpid/2.md) in this scenario.) Note, however, that the statements in this paragraph do not apply to the **SIGURG** signal generated for out-of-band data on a socket: this signal is always sent to either a process or a process group, depending on the value given to **F\_SETOWN**.

-

  The above behavior was accidentally dropped in Linux 2.6.12, and won't be restored. From Linux 2.6.32 onward, use **F\_SETOWN\_EX** to target **SIGIO** and **SIGURG** signals at a particular thread.

- **F\_GETOWN\_EX**

  Return the current file descriptor owner settings as defined by a previous **F\_SETOWN\_EX** operation. The information is returned in the structure pointed to by *arg*, which has the following form:

-

  ```
  struct f_owner_ex {
      int   type;
      pid_t pid;
  };
  ```

-

  The *type* field will have one of the values **F\_OWNER\_TID**, **F\_OWNER\_PID**, or **F\_OWNER\_PGRP**. The *pid* field is a positive integer representing a thread ID, process ID, or process group ID. See **F\_SETOWN\_EX** for more details.

- **F\_SETOWN\_EX**

  This operation performs a similar task to **F\_SETOWN**. It allows the caller to direct I/O availability signals to a specific thread, process, or process group. The caller specifies the target of signals via *arg*, which is a pointer to a *f\_owner\_ex* structure. The *type* field has one of the following values, which define how *pid* is interpreted:

  - **F\_OWNER\_TID**

    Send the signal to the thread whose thread ID (the value returned by a call to [**clone**(2)](/clone/2.md) or [**gettid**(2)](/gettid/2.md)) is specified in *pid*.

  - **F\_OWNER\_PID**

    Send the signal to the process whose ID is specified in *pid*.

  - **F\_OWNER\_PGRP**

    Send the signal to the process group whose ID is specified in *pid*. (Note that, unlike with **F\_SETOWN**, a process group ID is specified as a positive value here.)

- **F\_GETSIG**

  Return (as the function result) the signal sent when input or output becomes possible. A value of zero means **SIGIO** is sent. Any other value (including **SIGIO**) is the signal sent instead, and in this case additional info is available to the signal handler if installed with **SA\_SIGINFO**. *arg* is ignored.

- **F\_SETSIG**

  Set the signal sent when input or output becomes possible to the value given in *arg*. A value of zero means to send the default **SIGIO** signal. Any other value (including **SIGIO**) is the signal to send instead, and in this case additional info is available to the signal handler if installed with **SA\_SIGINFO**.

-

  By using **F\_SETSIG** with a nonzero value, and setting **SA\_SIGINFO** for the signal handler (see [**sigaction**(2)](/sigaction/2.md)), extra information about I/O events is passed to the handler in a *siginfo\_t* structure. If the *si\_code* field indicates the source is **SI\_SIGIO**, the *si\_fd* field gives the file descriptor associated with the event. Otherwise, there is no indication which file descriptors are pending, and you should use the usual mechanisms ([**select**(2)](/select/2.md), [**poll**(2)](/poll/2.md), [**read**(2)](/read/2.md) with **O\_NONBLOCK** set etc.) to determine which file descriptors are available for I/O.

-

  Note that the file descriptor provided in *si\_fd* is the one that was specified during the **F\_SETSIG** operation. This can lead to an unusual corner case. If the file descriptor is duplicated ([**dup**(2)](/dup/2.md) or similar), and the original file descriptor is closed, then I/O events will continue to be generated, but the *si\_fd* field will contain the number of the now closed file descriptor.

-

  By selecting a real time signal (value \>= **SIGRTMIN**), multiple I/O events may be queued using the same signal numbers. (Queuing is dependent on available memory.) Extra information is available if **SA\_SIGINFO** is set for the signal handler, as above.

-

  Note that Linux imposes a limit on the number of real-time signals that may be queued to a process (see [**getrlimit**(2)](/getrlimit/2.md) and [**signal**(7)](/signal/7.md)) and if this limit is reached, then the kernel reverts to delivering **SIGIO**, and this signal is delivered to the entire process rather than to a specific thread.

Using these mechanisms, a program can implement fully asynchronous I/O without using [**select**(2)](/select/2.md) or [**poll**(2)](/poll/2.md) most of the time.

The use of **O\_ASYNC** is specific to BSD and Linux. The only use of **F\_GETOWN** and **F\_SETOWN** specified in POSIX.1 is in conjunction with the use of the **SIGURG** signal on sockets. (POSIX does not specify the **SIGIO** signal.) **F\_GETOWN\_EX**, **F\_SETOWN\_EX**, **F\_GETSIG**, and **F\_SETSIG** are Linux-specific. POSIX has asynchronous I/O and the *aio\_sigevent* structure to achieve similar things; these are also available in Linux as part of the GNU C Library (glibc).

## RETURN VALUE

See [**fcntl**(2)](/fcntl/2.md).

- **F\_GETOWN**

  Value of file descriptor owner.

- **F\_GETSIG**

  Value of signal sent when read or write becomes possible, or zero for traditional **SIGIO** behavior.

- **F\_SETOWN** **F\_GETOWN\_EX** **F\_SETOWN\_EX** **F\_SETSIG**

  Zero.

On error, -1 is returned, and *errno* is set to indicate the error.

## ERRORS

See [**fcntl**(2)](/fcntl/2.md).

- **EINVAL**

  *op* is **F\_SETSIG** and *arg* is not an allowable signal number.

## STANDARDS

- **F\_GETOWN** **F\_SETOWN** **F\_GETOWN\_EX** **F\_SETOWN\_EX**

  POSIX.1-2024.

- **F\_GETSIG** **F\_SETSIG**

  Linux. (Define the **\_GNU\_SOURCE** macro to obtain these definitions.)

## HISTORY

- **F\_GETOWN** **F\_SETOWN**

  POSIX.1-2001. (To get their definitions, define either **\_XOPEN\_SOURCE** with the value 500 or greater, or **\_POSIX\_C\_SOURCE** with the value 200809L or greater.)

- **F\_GETOWN\_EX** **F\_SETOWN\_EX**

  POSIX.1-2024. Linux 2.6.32.

- **F\_GETSIG** **F\_SETSIG**

  Linux.

## BUGS

### F\_GETOWN

A limitation of the Linux system call conventions on some architectures (notably i386) means that if a (negative) process group ID to be returned by **F\_GETOWN** falls in the range -1 to -4095, then the return value is wrongly interpreted by glibc as an error in the system call; that is, the return value of **fcntl**() will be -1, and *errno* will contain the (positive) process group ID. The Linux-specific **F\_GETOWN\_EX** operation avoids this problem. Since glibc 2.11, glibc makes the kernel **F\_GETOWN** problem invisible by implementing **F\_GETOWN** using **F\_GETOWN\_EX**.

### F\_SETOWN

In Linux 2.4 and earlier, there is bug that can occur when an unprivileged process uses **F\_SETOWN** to specify the owner of a socket file descriptor as a process (group) other than the caller. In this case, **fcntl**() can return -1 with *errno* set to **EPERM**, even when the owner process (group) is one that the caller has permission to send signals to. Despite this error return, the file descriptor owner is set, and signals will be sent to the owner.

## SEE ALSO

[**fcntl**(2)](/fcntl/2.md)
