View | Details | Raw Unified | Return to bug 1029 | Differences between
and this patch

Collapse All | Expand All

(-)serverloop.c (+34 lines)
Lines 61-66 extern ServerOptions options; Link Here
61
/* XXX */
61
/* XXX */
62
extern Kex *xxx_kex;
62
extern Kex *xxx_kex;
63
extern Authctxt *the_authctxt;
63
extern Authctxt *the_authctxt;
64
extern int use_privsep;
64
65
65
static Buffer stdin_buffer;	/* Buffer for stdin data. */
66
static Buffer stdin_buffer;	/* Buffer for stdin data. */
66
static Buffer stdout_buffer;	/* Buffer for stdout data. */
67
static Buffer stdout_buffer;	/* Buffer for stdout data. */
Lines 90-95 static int client_alive_timeouts = 0; Link Here
90
91
91
static volatile sig_atomic_t child_terminated = 0;	/* The child has terminated. */
92
static volatile sig_atomic_t child_terminated = 0;	/* The child has terminated. */
92
93
94
/* Cleanup on signals (!use_privsep case only) */
95
static volatile sig_atomic_t received_sigterm = 0;
96
93
/* prototypes */
97
/* prototypes */
94
static void server_init_dispatch(void);
98
static void server_init_dispatch(void);
95
99
Lines 149-154 sigchld_handler(int sig) Link Here
149
	errno = save_errno;
153
	errno = save_errno;
150
}
154
}
151
155
156
static void
157
sigterm_handler(int sig)
158
{
159
	received_sigterm = sig;
160
}
161
152
/*
162
/*
153
 * Make packets from buffered stderr data, and buffer it for sending
163
 * Make packets from buffered stderr data, and buffer it for sending
154
 * to the client.
164
 * to the client.
Lines 500-505 server_loop(pid_t pid, int fdin_arg, int Link Here
500
	child_terminated = 0;
510
	child_terminated = 0;
501
	signal(SIGCHLD, sigchld_handler);
511
	signal(SIGCHLD, sigchld_handler);
502
512
513
	if (!use_privsep) {
514
		signal(SIGTERM, sigterm_handler);
515
		signal(SIGINT, sigterm_handler);
516
		signal(SIGQUIT, sigterm_handler);
517
	}
518
503
	/* Initialize our global variables. */
519
	/* Initialize our global variables. */
504
	fdin = fdin_arg;
520
	fdin = fdin_arg;
505
	fdout = fdout_arg;
521
	fdout = fdout_arg;
Lines 627-632 server_loop(pid_t pid, int fdin_arg, int Link Here
627
		wait_until_can_do_something(&readset, &writeset, &max_fd,
643
		wait_until_can_do_something(&readset, &writeset, &max_fd,
628
		    &nalloc, max_time_milliseconds);
644
		    &nalloc, max_time_milliseconds);
629
645
646
		if (received_sigterm) {
647
			logit("Exiting on signal %d", received_sigterm);
648
			/* Clean up sessions, utmp, etc. */
649
			cleanup_exit(255);
650
		}
651
630
		/* Process any channel events. */
652
		/* Process any channel events. */
631
		channel_after_select(readset, writeset);
653
		channel_after_select(readset, writeset);
632
654
Lines 747-752 server_loop2(Authctxt *authctxt) Link Here
747
	connection_in = packet_get_connection_in();
769
	connection_in = packet_get_connection_in();
748
	connection_out = packet_get_connection_out();
770
	connection_out = packet_get_connection_out();
749
771
772
	if (!use_privsep) {
773
		signal(SIGTERM, sigterm_handler);
774
		signal(SIGINT, sigterm_handler);
775
		signal(SIGQUIT, sigterm_handler);
776
	}
777
750
	notify_setup();
778
	notify_setup();
751
779
752
	max_fd = MAX(connection_in, connection_out);
780
	max_fd = MAX(connection_in, connection_out);
Lines 763-768 server_loop2(Authctxt *authctxt) Link Here
763
			channel_output_poll();
791
			channel_output_poll();
764
		wait_until_can_do_something(&readset, &writeset, &max_fd,
792
		wait_until_can_do_something(&readset, &writeset, &max_fd,
765
		    &nalloc, 0);
793
		    &nalloc, 0);
794
795
		if (received_sigterm) {
796
			logit("Exiting on signal %d", received_sigterm);
797
			/* Clean up sessions, utmp, etc. */
798
			cleanup_exit(255);
799
		}
766
800
767
		collect_children();
801
		collect_children();
768
		if (!rekeying) {
802
		if (!rekeying) {

Return to bug 1029