pty
struct pty pty = {0};
if (pty_open(&pty)) {
if (pty_detach(&pty)) {
if (pty_attach(&pty)) {
if (pty_drain(&pty)) {
int syscall = grab_syscall(pid, pty_buffer(&pty));
pty_close(&pty);
pty_open(struct pty *pty)
pty->master = master;
pty->slave = slave;
pty_close(struct pty *pty)
close(pty->slave);
close(pty->master);
pty_detach(struct pty *pty)
pty_attach(struct pty *pty)
if (ioctl(pty->slave, TIOCSCTTY, NULL) == -1) {
pty_drain(struct pty *pty)
char *buf = &pty->buf.storage[pty->buf.len];
size_t bufsize = sizeof(pty->buf.storage) - pty->buf.len;
n = read(pty->master, buf, bufsize);
pty->buf.len += n;
int pty_open(struct pty *);
void pty_close(struct pty *);
int pty_detach(struct pty *);
int pty_attach(struct pty *);
int pty_drain(struct pty *pty);
pty_buffer(struct pty *pty)
return pty->buf.storage;
int ch, fd, master = -1, slave, pty = 0, ldisc, nodaemon = 0;
pty = 1;
if (pty) {
relay(int device, int pty)
pfd[1].fd = pty;