]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lib/pty: save sigmask, add API to free all resources
authorKarel Zak <kzak@redhat.com>
Thu, 8 Aug 2019 13:34:00 +0000 (15:34 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 8 Oct 2019 11:11:54 +0000 (13:11 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
include/pty-session.h
lib/pty-session.c

index 2f685157d294b51a9a25cfee910e1b2dab144c9c..c139d6f97e0060e8f7f062c43e20289fc6e85134 100644 (file)
@@ -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);
index 4776c26dfc76643139278d2f5948eb7bd6316da7..1c6b559691bc57923c8e06ba141011ed981f1fd1 100644 (file)
@@ -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");