Gio.Cancellable.make_pollfd

### Method

# Gio Cancellablemake_pollfd

since: 2.22

#### Declaration [src]

    gboolean
    g_cancellable_make_pollfd (
      GCancellable* cancellable,
      GPollFD* pollfd
    )

#### Description [src]

Creates a `GPollFD` corresponding to `cancellable`; this can be passed to `g_poll()` and used to poll for cancellation. This is useful both for unix systems without a native poll and for portability to windows.

When this function returns `TRUE`, you should use `g_cancellable_release_fd()` to free up resources allocated for the `pollfd`. After a `FALSE` return, do not call g_cancellable_release_fd().

If this function returns `FALSE`, either no `cancellable` was given or resource limits prevent this function from allocating the necessary structures for polling. (On Linux, you will likely have reached the maximum number of file descriptors.) The suggested way to handle these cases is to ignore the `cancellable`.

You are not supposed to read from the fd yourself, just check for readable status. Reading to unset the readable status is done with g_cancellable_reset().

Note that in the event that a `GCancellable::cancelled` signal handler is currently running, this call will block until the handler has finished. Calling this function from a signal handler will therefore result in a deadlock.

Available since: 2.22

#### Parameters

`pollfd`

  Type: `GPollFD`

  A pointer to a `GPollFD`.

  The data is owned by the caller of the method.

#### Return value

Type: `gboolean`

`TRUE` if `pollfd` was successfully initialized, `FALSE` on failure to prepare the cancellable.