reptyr  0.8.0
About: reptyr is a utility for taking an existing running program and attaching it to a new terminal.
  Fossies Dox: reptyr-reptyr-0.8.0.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

attach.c File Reference
#include <sys/types.h>
#include <stdint.h>
#include <dirent.h>
#include <sys/syscall.h>
#include <sys/mman.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <fcntl.h>
#include <errno.h>
#include <termios.h>
#include <sys/ioctl.h>
#include <sys/wait.h>
#include <signal.h>
#include <limits.h>
#include <time.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include <sys/un.h>
#include "ptrace.h"
#include "reptyr.h"
#include "reallocarray.h"
#include "platform/platform.h"
Include dependency graph for attach.c:

Go to the source code of this file.


int fd_array_push (struct fd_array *fda, int fd)
static void do_unmap (struct ptrace_child *child, child_addr_t addr, unsigned long len)
static int do_fork (struct ptrace_child *child)
int do_setsid (struct ptrace_child *child)
static int do_dup2 (struct ptrace_child *child, int oldfd, int newfd)
int ignore_hup (struct ptrace_child *child, child_addr_t scratch_page)
void wait_for_stop (pid_t pid, int fd)
int copy_tty_state (pid_t pid, const char *pty)
int mmap_scratch (struct ptrace_child *child, child_addr_t *addr)
int grab_pid (pid_t pid, struct ptrace_child *child, child_addr_t *scratch)
int preflight_check (pid_t pid)
int attach_child (pid_t pid, const char *pty, int force_stdio)
int setup_steal_socket (struct steal_pty_state *steal)
int setup_steal_socket_child (struct steal_pty_state *steal)
int steal_child_pty (struct steal_pty_state *steal)
int steal_block_hup (struct steal_pty_state *steal)
int steal_cleanup_child (struct steal_pty_state *steal)
int steal_pty (pid_t pid, int *pty)

Function Documentation

◆ attach_child()

◆ copy_tty_state()

int copy_tty_state ( pid_t  pid,
const char *  pty 

Definition at line 189 of file attach.c.

References assert_nonzero, and get_process_tty_termios().

Referenced by attach_child().

◆ do_dup2()

static int do_dup2 ( struct ptrace_child child,
int  oldfd,
int  newfd 

Definition at line 126 of file attach.c.

References do_syscall, and ptrace_syscall_numbers().

Referenced by attach_child(), and steal_cleanup_child().

◆ do_fork()

static int do_fork ( struct ptrace_child child)

Definition at line 72 of file attach.c.

References do_syscall, and ptrace_syscall_numbers().

Referenced by do_setsid().

◆ do_setsid()

◆ do_unmap()

static void do_unmap ( struct ptrace_child child,
child_addr_t  addr,
unsigned long  len 

Definition at line 66 of file attach.c.

References do_syscall.

Referenced by attach_child(), and steal_pty().

◆ fd_array_push()

int fd_array_push ( struct fd_array fda,
int  fd 

Definition at line 48 of file attach.c.

References fd_array::allocated, fd_array::fds, fd_array::n, and xreallocarray().

◆ grab_pid()

◆ ignore_hup()

int ignore_hup ( struct ptrace_child child,
child_addr_t  scratch_page 

Definition at line 137 of file attach.c.

References do_syscall, and ptrace_memcpy_to_child().

Referenced by attach_child(), and steal_block_hup().

◆ mmap_scratch()

int mmap_scratch ( struct ptrace_child child,
child_addr_t addr 

◆ preflight_check()

int preflight_check ( pid_t  pid)

◆ setup_steal_socket()

int setup_steal_socket ( struct steal_pty_state steal)

◆ setup_steal_socket_child()

int setup_steal_socket_child ( struct steal_pty_state steal)

◆ steal_block_hup()

int steal_block_hup ( struct steal_pty_state steal)

◆ steal_child_pty()

◆ steal_cleanup_child()

◆ steal_pty()

◆ wait_for_stop()

void wait_for_stop ( pid_t  pid,
int  fd 

Definition at line 164 of file attach.c.

References check_proc_stopped(), and error().

Referenced by attach_child().