## ide-pty-intercept ide-pty-intercept |

## Functions

void | (*IdePtyInterceptCallback) ()
IdePtyFd | pty_fd_steal ()
IdePtyFd | ide_pty_intercept_create_master ()
IdePtyFd | ide_pty_intercept_create_slave ()
gboolean | ide_pty_intercept_init ()
IdePtyFd | ide_pty_intercept_get_fd ()
gboolean | ide_pty_intercept_set_size ()
void | ide_pty_intercept_clear ()
void | ide_pty_intercept_set_callback ()

## Types and Values

#define | IDE_PTY_FD_INVALID
#define | IDE_PTY_INTERCEPT_MAGIC
typedef | IdePtyFd
struct | IdePtyInterceptSide
int | rfd

## Description

## Functions

### IdePtyInterceptCallback ()

    void
    (*IdePtyInterceptCallback) (const IdePtyIntercept *intercept,
                                const IdePtyInterceptSide *side,
                                const guint8 *data,
                                gsize len,
                                gpointer user_data);

### pty_fd_steal ()

    IdePtyFd
    pty_fd_steal (IdePtyFd *fd);

### ide_pty_intercept_create_master ()

    IdePtyFd
    ide_pty_intercept_create_master (void);

Creates a new PTY master using `posix_openpt()`. Some fallbacks are provided for non-Linux systems where O_CLOEXEC and O_NONBLOCK may not be supported.

#### Returns

a FD that should be closed with `close()` if successful. Upon error, `IDE_PTY_FD_INVALID` (-1) is returned.

Since: 3.32

### ide_pty_intercept_create_slave ()

    IdePtyFd
    ide_pty_intercept_create_slave (IdePtyFd master_fd,
                                    gboolean blocking);

This creates a new slave to the PTY master `master_fd` .

This uses `grantpt()`, `unlockpt()`, and `ptsname()` to open a new PTY slave.

#### Parameters

master_fd | a pty master |
blocking | use `FALSE` to set O_NONBLOCK |

#### Returns

a FD for the slave PTY that should be closed with `close()`. Upon error, `IDE_PTY_FD_INVALID` (-1) is returned.

Since: 3.32

### ide_pty_intercept_init ()

    gboolean
    ide_pty_intercept_init (IdePtyIntercept *self,
                            IdePtyFd fd,
                            GMainContext *main_context);

Creates a enw IdePtyIntercept using the PTY master fd `fd` .

A new PTY slave is created that will communicate with `fd` . Additionally, a new PTY master is created that can communicate with another side, and will pass that information to `fd` after extracting any necessary information.

#### Parameters

self | a location of memory to store a IdePtyIntercept |
fd | the PTY master fd, possibly from a VtePty |
main_context | a GMainContext or `NULL` for thread-default. | [nullable]

#### Returns

`TRUE` if successful; otherwise `FALSE`

Since: 3.32

### ide_pty_intercept_get_fd ()

    IdePtyFd
    ide_pty_intercept_get_fd (IdePtyIntercept *self);

Gets a master PTY fd created by the IdePtyIntercept. This is suitable to use to create a slave fd which can be passed to a child process.

#### Parameters

self | a IdePtyIntercept |

#### Returns

A FD of a PTY master if successful, otherwise -1.

Since: 3.32

### ide_pty_intercept_set_size ()

    gboolean
    ide_pty_intercept_set_size (IdePtyIntercept *self,
                                guint rows,
                                guint columns);

Proxies a winsize across to the inferior. If the PTY is the controlling PTY for the process, then SIGWINCH will be signaled in the inferior process.

Since we can't track SIGWINCH cleanly in here, we rely on the external consuming program to notify us of SIGWINCH so that we can copy the new size across.

Since: 3.32

### ide_pty_intercept_clear ()

    void
    ide_pty_intercept_clear (IdePtyIntercept *self);

Cleans up a IdePtyIntercept previously initialized with `ide_pty_intercept_init()`.

This diconnects any GIOChannel that have been attached and releases any allocated memory.

It is invalid to use `self` after calling this function.

#### Parameters

self | a IdePtyIntercept |

Since: 3.32

### ide_pty_intercept_set_callback ()

    void
    ide_pty_intercept_set_callback (IdePtyIntercept *self,
                                    IdePtyInterceptSide *side,
                                    IdePtyInterceptCallback callback,
                                    gpointer user_data);

This sets the callback to execute every time data is received from a particular side of the intercept.

You may only set one per side.

#### Parameters

self | a IdePtyIntercept |
side | the side containing the data to watch |
callback | the callback to execute when data is received. | [scope notified]
user_data | closure data for `callback` |

Since: 3.32

## Types and Values

### IDE_PTY_FD_INVALID

    #define IDE_PTY_FD_INVALID (-1)

### IDE_PTY_INTERCEPT_MAGIC

    #define IDE_PTY_INTERCEPT_MAGIC (0x81723647)

### IdePtyFd

    typedef int                              IdePtyFd;

### struct IdePtyInterceptSide

    struct IdePtyInterceptSide {
      GIOChannel              *channel;
      guint                    in_watch;
      guint                    out_watch;
      gint                     read_prio;
      gint                     write_prio;
      GBytes                  *out_bytes;
      IdePtyInterceptCallback  callback;
      gpointer                 callback_data;
    };

### rfd

          int rfd = *fd;