Ruby  2.4.2p198(2017-09-14revision59899)
Data Structures | Macros | Functions | Variables
pty.c File Reference
#include "ruby/config.h"
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/file.h>
#include <fcntl.h>
#include <errno.h>
#include <ctype.h>
#include "internal.h"
#include "ruby/io.h"
#include "ruby/util.h"
#include <signal.h>
Include dependency graph for pty.c:

Go to the source code of this file.

Data Structures

struct  pty_info
 
struct  child_info
 

Macros

#define WIFSTOPPED(status)   (((status) & 0xff) == 0x7f)
 
#define DEVICELEN   16
 
#define ERROR_EXIT(str)
 

Functions

static VALUE echild_status (VALUE self)
 
static void getDevice (int *, int *, char [DEVICELEN], int)
 
static int chfunc (void *data, char *errbuf, size_t errbuf_len)
 
static void establishShell (int argc, VALUE *argv, struct pty_info *info, char SlaveName[DEVICELEN])
 
static int get_device_once (int *master, int *slave, char SlaveName[DEVICELEN], int nomesg, int fail)
 
static VALUE pty_close_pty (VALUE assoc)
 
static VALUE pty_open (VALUE klass)
 
static VALUE pty_detach_process (struct pty_info *info)
 
static VALUE pty_getpty (int argc, VALUE *argv, VALUE self)
 
 NORETURN (static void raise_from_check(rb_pid_t pid, int status))
 
static void raise_from_check (rb_pid_t pid, int status)
 
static VALUE pty_check (int argc, VALUE *argv, VALUE self)
 
void Init_pty (void)
 

Variables

static VALUE eChildExited
 
static VALUE cPTY
 

Macro Definition Documentation

◆ DEVICELEN

#define DEVICELEN   16

Definition at line 51 of file pty.c.

Referenced by get_device_once(), pty_getpty(), and pty_open().

◆ ERROR_EXIT

#define ERROR_EXIT (   str)
Value:
do { \
strlcpy(errbuf, (str), errbuf_len); \
return -1; \
} while (0)

Referenced by chfunc().

◆ WIFSTOPPED

#define WIFSTOPPED (   status)    (((status) & 0xff) == 0x7f)

Definition at line 34 of file pty.c.

Referenced by raise_from_check().

Function Documentation

◆ chfunc()

static int chfunc ( void *  data,
char *  errbuf,
size_t  errbuf_len 
)
static

◆ echild_status()

static VALUE echild_status ( VALUE  self)
static

Definition at line 71 of file pty.c.

References rb_intern, and rb_ivar_get().

Referenced by Init_pty().

◆ establishShell()

static void establishShell ( int  argc,
VALUE argv,
struct pty_info info,
char  SlaveName[DEVICELEN] 
)
static

◆ get_device_once()

static int get_device_once ( int *  master,
int *  slave,
char  SlaveName[DEVICELEN],
int  nomesg,
int  fail 
)
static

◆ getDevice()

static void getDevice ( int *  master,
int *  slave,
char  SlaveName[DEVICELEN],
int  nomesg 
)
static

Definition at line 457 of file pty.c.

References get_device_once(), and rb_gc().

Referenced by establishShell(), and pty_open().

◆ Init_pty()

void Init_pty ( void  )

◆ NORETURN()

NORETURN ( static void   raise_from_checkrb_pid_t pid, int status)

Referenced by pty_getpty().

◆ pty_check()

static VALUE pty_check ( int  argc,
VALUE argv,
VALUE  self 
)
static

Definition at line 674 of file pty.c.

References NUM2PIDT, Qnil, raise_from_check(), rb_last_status_get(), rb_scan_args(), rb_waitpid(), RTEST, UNREACHABLE, and WNOHANG.

Referenced by Init_pty().

◆ pty_close_pty()

static VALUE pty_close_pty ( VALUE  assoc)
static

Definition at line 466 of file pty.c.

References Qnil, rb_ary_entry(), rb_io_close(), RB_TYPE_P, RFILE, and T_FILE.

Referenced by pty_open().

◆ pty_detach_process()

static VALUE pty_detach_process ( struct pty_info info)
static

Definition at line 550 of file pty.c.

References pty_info::child_pid, Qnil, rb_detach_process(), rb_waitpid(), and WNOHANG.

Referenced by pty_getpty().

◆ pty_getpty()

static VALUE pty_getpty ( int  argc,
VALUE argv,
VALUE  self 
)
static

◆ pty_open()

static VALUE pty_open ( VALUE  klass)
static

◆ raise_from_check()

static void raise_from_check ( rb_pid_t  pid,
int  status 
)
static

Variable Documentation

◆ cPTY

VALUE cPTY
static

Definition at line 698 of file pty.c.

Referenced by Init_pty().

◆ eChildExited

VALUE eChildExited
static

Definition at line 65 of file pty.c.

Referenced by Init_pty(), and raise_from_check().