diff --git a/include/pty-session.h b/include/pty-session.h index 2f685157d..c139d6f97 100644 --- a/include/pty-session.h +++ b/include/pty-session.h @@ -41,8 +41,8 @@ struct ul_pty { void ul_pty_init_debug(int mask); struct ul_pty *ul_new_pty(int is_stdin_tty); +void ul_free_pty(struct ul_pty *pty); -sigset_t *ul_pty_get_orig_sigset(struct ul_pty *pty); int ul_pty_get_delivered_signal(struct ul_pty *pty); void ul_pty_set_callback_data(struct ul_pty *pty, void *data); diff --git a/lib/pty-session.c b/lib/pty-session.c index 4776c26df..1c6b55969 100644 --- a/lib/pty-session.c +++ b/lib/pty-session.c @@ -66,12 +66,12 @@ struct ul_pty *ul_new_pty(int is_stdin_tty) return pty; } -sigset_t *ul_pty_get_orig_sigset(struct ul_pty *pty) +void ul_free_pty(struct ul_pty *pty) { - assert(pty); - return &pty->orgsig; + free(pty); } + int ul_pty_get_delivered_signal(struct ul_pty *pty) { assert(pty); @@ -128,6 +128,9 @@ int ul_pty_setup(struct ul_pty *pty) struct termios slave_attrs; int rc; + /* save the current signals setting */ + sigprocmask(0, NULL, &pty->orgsig); + if (pty->isterm) { DBG(SETUP, ul_debugobj(pty, "create for terminal")); @@ -590,8 +593,6 @@ int main(int argc, char *argv[]) cb->child_wait = wait_for_child; cb->child_sigstop = child_sigstop; - sigprocmask(SIG_BLOCK, NULL, ul_pty_get_orig_sigset(ss.pty)); - if (ul_pty_setup(ss.pty)) err(EXIT_FAILURE, "failed to create pseudo-terminal");