From 15b5d9882db7f678c09f97ebbe66eadd9b05a9aa Mon Sep 17 00:00:00 2001 From: simon Date: Fri, 17 Dec 2004 14:25:53 +0000 Subject: [PATCH] Jacob has pointed out why SIGCHLD was blocked, so I've updated the comment when I unblock it in pty.c to reflect reality. Also I've moved block_signal() out of pterm.c into signal.c, so I can conveniently use it for unblocking SIGCHLD rather than having to reinvent it in pty.c. git-svn-id: svn://svn.tartarus.org/sgt/putty@5006 cda61777-01e9-0310-a592-d414129be87e --- unix/pterm.c | 11 ----------- unix/pty.c | 13 ++++--------- unix/signal.c | 14 ++++++++++++++ unix/unix.h | 3 ++- 4 files changed, 20 insertions(+), 21 deletions(-) diff --git a/unix/pterm.c b/unix/pterm.c index 526e4941..23ef37fb 100644 --- a/unix/pterm.c +++ b/unix/pterm.c @@ -2551,17 +2551,6 @@ int do_cmdline(int argc, char **argv, int do_everything, return err; } -static void block_signal(int sig, int block_it) { - sigset_t ss; - - sigemptyset(&ss); - sigaddset(&ss, sig); - if(sigprocmask(block_it ? SIG_BLOCK : SIG_UNBLOCK, &ss, 0) < 0) { - perror("sigprocmask"); - exit(1); - } -} - /* * This function retrieves the character set encoding of a font. It * returns the character set without the X11 hack (in case the user diff --git a/unix/pty.c b/unix/pty.c index b9bd510b..bef9f2fa 100644 --- a/unix/pty.c +++ b/unix/pty.c @@ -621,18 +621,13 @@ static const char *pty_init(void *frontend, void **backend_handle, Config *cfg, /* * SIGINT and SIGQUIT may have been set to ignored by our * parent, particularly by things like sh -c 'pterm &' and - * some window managers. SIGCHLD, meanwhile, has been - * tinkered with by the watchdog process. Reverse all this - * for our child process. + * some window managers. SIGCHLD, meanwhile, was blocked + * during pt_main() startup. Reverse all this for our child + * process. */ putty_signal(SIGINT, SIG_DFL); putty_signal(SIGQUIT, SIG_DFL); - { - sigset_t set; - sigemptyset(&set); - sigaddset(&set, SIGCHLD); - sigprocmask(SIG_UNBLOCK, &set, NULL); - } + block_signal(SIGCHLD, 0); if (pty_argv) execvp(pty_argv[0], pty_argv); else { diff --git a/unix/signal.c b/unix/signal.c index 4e103b73..9b0ad5ea 100644 --- a/unix/signal.c +++ b/unix/signal.c @@ -1,4 +1,6 @@ #include +#include +#include /* * Calling signal() is a non-portable, as it varies in meaning between @@ -23,6 +25,18 @@ void (*putty_signal(int sig, void (*func)(int)))(int) { return old.sa_handler; } +void block_signal(int sig, int block_it) +{ + sigset_t ss; + + sigemptyset(&ss); + sigaddset(&ss, sig); + if(sigprocmask(block_it ? SIG_BLOCK : SIG_UNBLOCK, &ss, 0) < 0) { + perror("sigprocmask"); + exit(1); + } +} + /* Local Variables: c-basic-offset:4 diff --git a/unix/unix.h b/unix/unix.h index 90c6ec2f..969cdbbf 100644 --- a/unix/unix.h +++ b/unix/unix.h @@ -111,8 +111,9 @@ void unix_setup_config_box(struct controlbox *b, int midsession, void *window); #define strnicmp strncasecmp #define stricmp strcasecmp -/* BSD-semantics version of signal() */ +/* BSD-semantics version of signal(), and another helpful function */ void (*putty_signal(int sig, void (*func)(int)))(int); +void block_signal(int sig, int block_it); /* * Exports from unicode.c. -- 2.11.0