From: Karel Zak Date: Thu, 8 Aug 2019 13:34:00 +0000 (+0200) Subject: lib/pty: save sigmask, add API to free all resources X-Git-Tag: v2.35-rc1~130 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ab61a038814e6a4fe618792e791b12afa7f87891;p=thirdparty%2Futil-linux.git lib/pty: save sigmask, add API to free all resources Signed-off-by: Karel Zak --- diff --git a/include/pty-session.h b/include/pty-session.h index 2f685157d2..c139d6f97e 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 4776c26dfc..1c6b559691 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");