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

Collapse All | Expand All

(-)openssh-3.8p1/channels.c (-2 / +2 lines)
Lines 1353-1359 Link Here
1353
	if (c->rfd != -1 &&
1353
	if (c->rfd != -1 &&
1354
	    FD_ISSET(c->rfd, readset)) {
1354
	    FD_ISSET(c->rfd, readset)) {
1355
		len = read(c->rfd, buf, sizeof(buf));
1355
		len = read(c->rfd, buf, sizeof(buf));
1356
		if (len < 0 && (errno == EINTR || errno == EAGAIN))
1356
		if (len < 0 && errno == EINTR)
1357
			return 1;
1357
			return 1;
1358
		if (len <= 0) {
1358
		if (len <= 0) {
1359
			debug2("channel %d: read<=0 rfd %d len %d",
1359
			debug2("channel %d: read<=0 rfd %d len %d",
Lines 1468-1474 Link Here
1468
			len = read(c->efd, buf, sizeof(buf));
1468
			len = read(c->efd, buf, sizeof(buf));
1469
			debug2("channel %d: read %d from efd %d",
1469
			debug2("channel %d: read %d from efd %d",
1470
			    c->self, len, c->efd);
1470
			    c->self, len, c->efd);
1471
			if (len < 0 && (errno == EINTR || errno == EAGAIN))
1471
			if (len < 0 && errno == EINTR)
1472
				return 1;
1472
				return 1;
1473
			if (len <= 0) {
1473
			if (len <= 0) {
1474
				debug2("channel %d: closing read-efd %d",
1474
				debug2("channel %d: closing read-efd %d",
(-)openssh-3.8p1/serverloop.c (-8 / +18 lines)
Lines 245-250 Link Here
245
	struct timeval tv, *tvp;
245
	struct timeval tv, *tvp;
246
	int ret;
246
	int ret;
247
	int client_alive_scheduled = 0;
247
	int client_alive_scheduled = 0;
248
	int program_alive_scheduled = 0;
248
249
249
	/*
250
	/*
250
	 * if using client_alive, set the max timeout accordingly,
251
	 * if using client_alive, set the max timeout accordingly,
Lines 282-287 Link Here
282
		 * the client, try to get some more data from the program.
283
		 * the client, try to get some more data from the program.
283
		 */
284
		 */
284
		if (packet_not_very_much_data_to_write()) {
285
		if (packet_not_very_much_data_to_write()) {
286
			program_alive_scheduled = child_terminated;
285
			if (!fdout_eof)
287
			if (!fdout_eof)
286
				FD_SET(fdout, *readsetp);
288
				FD_SET(fdout, *readsetp);
287
			if (!fderr_eof)
289
			if (!fderr_eof)
Lines 327-334 Link Here
327
		memset(*writesetp, 0, *nallocp);
329
		memset(*writesetp, 0, *nallocp);
328
		if (errno != EINTR)
330
		if (errno != EINTR)
329
			error("select: %.100s", strerror(errno));
331
			error("select: %.100s", strerror(errno));
330
	} else if (ret == 0 && client_alive_scheduled)
332
	} else if (ret == 0) {
331
		client_alive_check();
333
		if (client_alive_scheduled)
334
			client_alive_check();
335
		if (program_alive_scheduled && fdin_is_tty) {
336
			if (!fdout_eof)
337
				FD_SET(fdout, *readsetp);
338
			if (!fderr_eof)
339
				FD_SET(fderr, *readsetp);
340
		}
341
	}
332
342
333
	notify_done(*readsetp);
343
	notify_done(*readsetp);
334
}
344
}
Lines 371-377 Link Here
371
	/* Read and buffer any available stdout data from the program. */
381
	/* Read and buffer any available stdout data from the program. */
372
	if (!fdout_eof && FD_ISSET(fdout, readset)) {
382
	if (!fdout_eof && FD_ISSET(fdout, readset)) {
373
		len = read(fdout, buf, sizeof(buf));
383
		len = read(fdout, buf, sizeof(buf));
374
		if (len < 0 && (errno == EINTR || errno == EAGAIN)) {
384
		if (len < 0 && errno == EINTR) {
375
			/* do nothing */
385
			/* do nothing */
376
		} else if (len <= 0) {
386
		} else if (len <= 0) {
377
			fdout_eof = 1;
387
			fdout_eof = 1;
Lines 383-389 Link Here
383
	/* Read and buffer any available stderr data from the program. */
393
	/* Read and buffer any available stderr data from the program. */
384
	if (!fderr_eof && FD_ISSET(fderr, readset)) {
394
	if (!fderr_eof && FD_ISSET(fderr, readset)) {
385
		len = read(fderr, buf, sizeof(buf));
395
		len = read(fderr, buf, sizeof(buf));
386
		if (len < 0 && (errno == EINTR || errno == EAGAIN)) {
396
		if (len < 0 && errno == EINTR) {
387
			/* do nothing */
397
			/* do nothing */
388
		} else if (len <= 0) {
398
		} else if (len <= 0) {
389
			fderr_eof = 1;
399
			fderr_eof = 1;
Lines 715-721 Link Here
715
}
725
}
716
726
717
static void
727
static void
718
collect_children(void)
728
collect_children(fd_set **readsetp)
719
{
729
{
720
	pid_t pid;
730
	pid_t pid;
721
	sigset_t oset, nset;
731
	sigset_t oset, nset;
Lines 729-735 Link Here
729
		while ((pid = waitpid(-1, &status, WNOHANG)) > 0 ||
739
		while ((pid = waitpid(-1, &status, WNOHANG)) > 0 ||
730
		    (pid < 0 && errno == EINTR))
740
		    (pid < 0 && errno == EINTR))
731
			if (pid > 0)
741
			if (pid > 0)
732
				session_close_by_pid(pid, status);
742
				session_close_by_pid(pid, status, readsetp);
733
		child_terminated = 0;
743
		child_terminated = 0;
734
	}
744
	}
735
	sigprocmask(SIG_SETMASK, &oset, NULL);
745
	sigprocmask(SIG_SETMASK, &oset, NULL);
Lines 765-771 Link Here
765
		wait_until_can_do_something(&readset, &writeset, &max_fd,
775
		wait_until_can_do_something(&readset, &writeset, &max_fd,
766
		    &nalloc, 0);
776
		    &nalloc, 0);
767
777
768
		collect_children();
778
		collect_children(&readset);
769
		if (!rekeying) {
779
		if (!rekeying) {
770
			channel_after_select(readset, writeset);
780
			channel_after_select(readset, writeset);
771
			if (packet_need_rekeying()) {
781
			if (packet_need_rekeying()) {
Lines 779-785 Link Here
779
			break;
789
			break;
780
		process_output(writeset);
790
		process_output(writeset);
781
	}
791
	}
782
	collect_children();
792
	collect_children(&readset);
783
793
784
	if (readset)
794
	if (readset)
785
		xfree(readset);
795
		xfree(readset);
(-)openssh-3.8p1/session.c (-3 / +10 lines)
Lines 1962-1968 Link Here
1962
}
1962
}
1963
1963
1964
static void
1964
static void
1965
session_exit_message(Session *s, int status)
1965
session_exit_message(Session *s, int status, fd_set **readsetp)
1966
{
1966
{
1967
	Channel *c;
1967
	Channel *c;
1968
1968
Lines 1972-1977 Link Here
1972
	debug("session_exit_message: session %d channel %d pid %ld",
1972
	debug("session_exit_message: session %d channel %d pid %ld",
1973
	    s->self, s->chanid, (long)s->pid);
1973
	    s->self, s->chanid, (long)s->pid);
1974
1974
1975
	if (s->ptyfd != -1) {
1976
		if (c->rfd != -1)
1977
			FD_SET(c->rfd, *readsetp);
1978
		if (c->efd != -1)
1979
			FD_SET(c->efd, *readsetp);
1980
	}
1981
1975
	if (WIFEXITED(status)) {
1982
	if (WIFEXITED(status)) {
1976
		channel_request_start(s->chanid, "exit-status", 0);
1983
		channel_request_start(s->chanid, "exit-status", 0);
1977
		packet_put_int(WEXITSTATUS(status));
1984
		packet_put_int(WEXITSTATUS(status));
Lines 2027-2033 Link Here
2027
}
2034
}
2028
2035
2029
void
2036
void
2030
session_close_by_pid(pid_t pid, int status)
2037
session_close_by_pid(pid_t pid, int status, fd_set **readsetp)
2031
{
2038
{
2032
	Session *s = session_by_pid(pid);
2039
	Session *s = session_by_pid(pid);
2033
	if (s == NULL) {
2040
	if (s == NULL) {
Lines 2036-2042 Link Here
2036
		return;
2043
		return;
2037
	}
2044
	}
2038
	if (s->chanid != -1)
2045
	if (s->chanid != -1)
2039
		session_exit_message(s, status);
2046
		session_exit_message(s, status, readsetp);
2040
	session_close(s);
2047
	session_close(s);
2041
}
2048
}
2042
2049
(-)openssh-3.8p1/session.h (-1 / +1 lines)
Lines 60-66 Link Here
60
60
61
int	 session_open(Authctxt *, int);
61
int	 session_open(Authctxt *, int);
62
int	 session_input_channel_req(Channel *, const char *);
62
int	 session_input_channel_req(Channel *, const char *);
63
void	 session_close_by_pid(pid_t, int);
63
void	 session_close_by_pid(pid_t, int, fd_set **);
64
void	 session_close_by_channel(int, void *);
64
void	 session_close_by_channel(int, void *);
65
void	 session_destroy_all(void (*)(Session *));
65
void	 session_destroy_all(void (*)(Session *));
66
void	 session_pty_cleanup2(Session *);
66
void	 session_pty_cleanup2(Session *);

Return to bug 52