mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-10 09:58:01 +00:00
uxpgnt: factor out setup_sigchld_handler().
I'm about to need to call this from multiple places.
This commit is contained in:
parent
ff1a297f77
commit
e49ae68ff1
@ -30,6 +30,8 @@ void cmdline_error(const char *fmt, ...)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void setup_sigchld_handler(void);
|
||||||
|
|
||||||
struct uxpgnt_client {
|
struct uxpgnt_client {
|
||||||
FILE *logfp;
|
FILE *logfp;
|
||||||
strbuf *debug_prompt_buf;
|
strbuf *debug_prompt_buf;
|
||||||
@ -291,14 +293,29 @@ void pageant_fork_and_print_env(bool retain_tty)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int signalpipe[2];
|
static int signalpipe[2] = { -1, -1 };
|
||||||
|
|
||||||
void sigchld(int signum)
|
static void sigchld(int signum)
|
||||||
{
|
{
|
||||||
if (write(signalpipe[1], "x", 1) <= 0)
|
if (write(signalpipe[1], "x", 1) <= 0)
|
||||||
/* not much we can do about it */;
|
/* not much we can do about it */;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void setup_sigchld_handler(void)
|
||||||
|
{
|
||||||
|
if (signalpipe[0] >= 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set up the pipe we'll use to tell us about SIGCHLD.
|
||||||
|
*/
|
||||||
|
if (pipe(signalpipe) < 0) {
|
||||||
|
perror("pipe");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
putty_signal(SIGCHLD, sigchld);
|
||||||
|
}
|
||||||
|
|
||||||
#define TTY_LIFE_POLL_INTERVAL (TICKSPERSEC * 30)
|
#define TTY_LIFE_POLL_INTERVAL (TICKSPERSEC * 30)
|
||||||
static void *dummy_timer_ctx;
|
static void *dummy_timer_ctx;
|
||||||
static void tty_life_timer(void *ctx, unsigned long now)
|
static void tty_life_timer(void *ctx, unsigned long now)
|
||||||
@ -934,7 +951,6 @@ void run_agent(FILE *logfp, const char *symlink_path)
|
|||||||
/*
|
/*
|
||||||
* Lifetime preparations.
|
* Lifetime preparations.
|
||||||
*/
|
*/
|
||||||
signalpipe[0] = signalpipe[1] = -1;
|
|
||||||
if (life == LIFE_X11) {
|
if (life == LIFE_X11) {
|
||||||
struct X11Display *disp;
|
struct X11Display *disp;
|
||||||
void *greeting;
|
void *greeting;
|
||||||
@ -1018,15 +1034,7 @@ void run_agent(FILE *logfp, const char *symlink_path)
|
|||||||
pid_t agentpid, pid;
|
pid_t agentpid, pid;
|
||||||
|
|
||||||
agentpid = getpid();
|
agentpid = getpid();
|
||||||
|
setup_sigchld_handler();
|
||||||
/*
|
|
||||||
* Set up the pipe we'll use to tell us about SIGCHLD.
|
|
||||||
*/
|
|
||||||
if (pipe(signalpipe) < 0) {
|
|
||||||
perror("pipe");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
putty_signal(SIGCHLD, sigchld);
|
|
||||||
|
|
||||||
pid = fork();
|
pid = fork();
|
||||||
if (pid < 0) {
|
if (pid < 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user