30#include "gdbsupport/gdb_select.h"
36#include "gdbsupport/job-control.h"
37#include "gdbsupport/scoped_ignore_sigttou.h"
39#ifdef HAVE_SYS_IOCTL_H
88 pid_t process_group = 0;
118static gdb::optional<sighandler_t> sigquit_ours;
175 gdb_printf(gdb_stderr, "[%s failed in terminal_inferior: %s]\n", \
176 what, safe_strerror (errno))
194 tinfo->process_group =
inf->
pid;
221 struct stat other_tty;
224 res = stat (tty, &other_tty);
226 return TRIBOOL_UNKNOWN;
228 res = fstat (STDIN_FILENO, &gdb_tty);
230 return TRIBOOL_UNKNOWN;
232 return ((gdb_tty.st_dev == other_tty.st_dev
233 && gdb_tty.st_ino == other_tty.st_ino)
271 if (res == TRIBOOL_UNKNOWN)
289 if (res == TRIBOOL_UNKNOWN)
293 return res == TRIBOOL_TRUE;
323 scoped_ignore_sigttou ignore_sigttou;
326 result = fcntl (0, F_SETFL, tinfo->
tflags);
327 OOPSY (
"fcntl F_SETFL");
331 OOPSY (
"setting tty state");
337 sigquit_ours = signal (SIGQUIT, SIG_IGN);
351 result =
tcsetpgrp (0, tinfo->process_group);
366 "[tcsetpgrp failed in child_terminal_inferior: %s]\n",
367 safe_strerror (errno));
434 tinfo->
tflags = fcntl (0, F_GETFL, 0);
452 int result ATTRIBUTE_UNUSED;
456 scoped_ignore_sigttou ignore_sigttou;
475 "[tcsetpgrp failed in child_terminal_ours: %s]\n",
476 safe_strerror (errno));
487 if (sigquit_ours.has_value ())
488 signal (SIGQUIT, *sigquit_ours);
489 sigquit_ours.reset ();
511 if (thr->executing ())
516 if (thr->has_pending_waitstatus ())
529 kill (resumed->
inf->
pid, SIGINT);
558 kill (-term_pgrp, SIGINT);
570 gdb_assert (
inf->
pid != 0);
581 gdb_assert_not_reached (
"no inferior resumed in the fg found");
630 *tinfo_to = *tinfo_from;
667 gdb_printf (_(
"This GDB does not control a terminal.\n"));
678 "(currently saved by GDB):\n"));
689#define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR)
707 if (
flags & O_NONBLOCK)
709 flags &= ~O_NONBLOCK;
712#if defined (O_NDELAY)
716 if (
flags & O_NDELAY)
721 if (
flags & O_APPEND)
725#if defined (O_BINARY)
737 gdb_printf (
"Process group = %d\n", (
int) tinfo->process_group);
760#if !defined(__GO32__) && !defined(_WIN32)
770 safe_strerror (errno));
781#if !defined(__GO32__) && !defined(_WIN32)
788 tty = open (
"/dev/tty", O_RDWR);
791 scoped_ignore_sigttou ignore_sigttou;
793 ioctl (tty, TIOCNOTTY, 0);
821 if (ioctl (tty, TIOCSCTTY, 0) == -1)
824 warning (_(
"GDB: Failed to set controlling terminal: %s"),
825 safe_strerror (errno));
909 warning (_(
"Failed to create new terminal session: setsid: %s"),
910 safe_strerror (errno));
935 _(
"Print inferior's saved terminal status."));
target_terminal_state terminal_state
void set(unsigned key, void *datum)
static void info(const char *arg, int from_tty)
struct cmd_list_element * add_info(const char *name, cmd_simple_func_ftype *fun, const char *doc)
all_non_exited_threads_range all_non_exited_threads(process_stratum_target *proc_target=nullptr, ptid_t filter_ptid=minus_one_ptid)
mach_port_t kern_return_t mach_port_t mach_msg_type_name_t msgportsPoly mach_port_t kern_return_t pid_t pid mach_port_t kern_return_t mach_port_t task mach_port_t kern_return_t int flags
int tcsetpgrp(int fd, pid_t pgid)
struct inferior * current_inferior(void)
all_inferiors_range all_inferiors(process_stratum_target *proc_target=nullptr)
c_c_handler_ftype * install_sigint_handler(c_c_handler_ftype *fn)
void new_tty_postfork(void)
static struct terminal_info our_terminal_info
void child_terminal_info(struct target_ops *self, const char *args, int from_tty)
static void check_syscall(const char *msg, int result)
static std::string inferior_thisrun_terminal
void initialize_stdin_serial(void)
void copy_terminal_info(struct inferior *to, struct inferior *from)
static gdb::optional< sighandler_t > sigint_ours
tribool is_gdb_terminal(const char *tty)
void set_sigint_trap(void)
void child_terminal_ours(struct target_ops *self)
static void info_terminal_command(const char *arg, int from_tty)
static bool sharing_input_terminal(inferior *inf)
void child_terminal_init(struct target_ops *self)
void new_tty_prefork(std::string ttyname)
static serial_ttystate initial_gdb_ttystate
void child_pass_ctrlc(struct target_ops *self)
void gdb_save_tty_state(void)
void child_terminal_ours_for_output(struct target_ops *self)
void child_interrupt(struct target_ops *self)
static void child_terminal_ours_1(target_terminal_state)
void child_terminal_inferior(struct target_ops *self)
static void pass_signal(int)
static struct terminal_info * get_inflow_inferior_data(struct inferior *)
void _initialize_inflow()
static const registry< inferior >::key< terminal_info > inflow_inferior_data
pid_t create_tty_session(void)
void child_terminal_save_inferior(struct target_ops *self)
void set_initial_gdb_ttystate(void)
void clear_sigint_trap(void)
static void inflow_inferior_exit(struct inferior *inf)
static int gdb_has_a_terminal(void)
static target_terminal_state gdb_tty_state
void swap_terminal_info(inferior *a, inferior *b)
static struct serial * stdin_serial
observable< struct inferior * > inferior_exit
void serial_print_tty_state(struct serial *scb, serial_ttystate ttystate, struct ui_file *stream)
int serial_set_tty_state(struct serial *scb, serial_ttystate ttystate)
serial_ttystate serial_copy_tty_state(struct serial *scb, serial_ttystate ttystate)
serial_ttystate serial_get_tty_state(struct serial *scb)
struct serial * serial_fdopen(const int fd)
terminal_info & operator=(const terminal_info &)=default
void gdb_printf(struct ui_file *stream, const char *format,...)