static int close_inferior_connection (void *ctx) { struct annotate_two *a2 = (struct annotate_two *)ctx; if (!a2) { logger_write_pos (logger, __FILE__, __LINE__, "close_inferior_connection error"); return -1; } if (a2->pty_pair) pty_pair_destroy (a2->pty_pair); return 0; }
int a2_open_new_tty(struct annotate_two *a2, int *inferior_stdin, int *inferior_stdout) { if (a2->pty_pair) pty_pair_destroy(a2->pty_pair); a2->pty_pair = pty_pair_create(); if (!a2->pty_pair) { logger_write_pos(logger, __FILE__, __LINE__, "pty_pair_create failed"); return -1; } *inferior_stdin = pty_pair_get_masterfd(a2->pty_pair); *inferior_stdout = pty_pair_get_masterfd(a2->pty_pair); commands_issue_command(a2, ANNOTATE_TTY, pty_pair_get_slavename(a2->pty_pair), 1); return 0; }
static int tgdb_open_new_tty(struct tgdb *tgdb, int *inferior_stdin, int *inferior_stdout) { if (tgdb->pty_pair) pty_pair_destroy(tgdb->pty_pair); tgdb->pty_pair = pty_pair_create(); if (!tgdb->pty_pair) { clog_error(CLOG_CGDB, "pty_pair_create failed"); return -1; } *inferior_stdin = pty_pair_get_masterfd(tgdb->pty_pair); *inferior_stdout = pty_pair_get_masterfd(tgdb->pty_pair); tgdb_request_ptr request_ptr; request_ptr = (tgdb_request_ptr)cgdb_malloc(sizeof (struct tgdb_request)); request_ptr->header = TGDB_REQUEST_TTY; request_ptr->choice.tty_command.slavename = pty_pair_get_slavename(tgdb->pty_pair); tgdb_run_or_queue_request(tgdb, request_ptr, true); return 0; }