GLibUnix.fd_add
Description: Reference for GLibUnix.fd_add

### Function

# GLibUnixfd_add

since: 2.36

#### Declaration [src]

    guint
    g_unix_fd_add (
      gint fd,
      GIOCondition condition,
      GUnixFDSourceFunc function,
      gpointer user_data
    )

#### Description [src]

Sets a function to be called when the IO condition, as specified by `condition` becomes true for `fd`.

`function` will be called when the specified IO condition becomes `TRUE`. The function is expected to clear whatever event caused the IO condition to become true and return `TRUE` in order to be notified when it happens again. If `function` returns `FALSE` then the watch will be cancelled.

The return value of this function can be passed to `g_source_remove()` to cancel the watch at any time that it exists.

The source will never close the fd — you must do it yourself.

Available since: 2.36

This function is not directly available to language bindings.

#### Parameters

`fd`

  Type: `gint`

  A file descriptor.

`condition`

  Type: `GIOCondition`

  IO conditions to watch for on `fd`.

`function`

  Type: `GUnixFDSourceFunc`

  A `GUnixFDSourceFunc`.

`user_data`

  Type: `gpointer`

  Data to pass to `function`.

  The argument can be `NULL`.
  The data is owned by the caller of the function.

#### Return value

Type: `guint`

The ID (greater than 0) of the event source.