summaryrefslogtreecommitdiff
path: root/session.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2001-10-10 15:14:37 +1000
committerDamien Miller <djm@mindrot.org>2001-10-10 15:14:37 +1000
commit52b77beb6560c409dfaaec6e61a8f2a2bf53d7d8 (patch)
tree361b15f34c99af10cafad3198d7727893c019b81 /session.c
parentc71f4e40b6d8cdf1c0d83381945841e66c127a95 (diff)
- markus@cvs.openbsd.org 2001/10/09 21:59:41
[channels.c channels.h serverloop.c session.c session.h] simplify session close: no more delayed session_close, no more blocking wait() calls.
Diffstat (limited to 'session.c')
-rw-r--r--session.c44
1 files changed, 21 insertions, 23 deletions
diff --git a/session.c b/session.c
index c1305da6a..0d6ebdaea 100644
--- a/session.c
+++ b/session.c
@@ -33,7 +33,7 @@
33 */ 33 */
34 34
35#include "includes.h" 35#include "includes.h"
36RCSID("$OpenBSD: session.c,v 1.105 2001/10/09 19:32:49 markus Exp $"); 36RCSID("$OpenBSD: session.c,v 1.106 2001/10/09 21:59:41 markus Exp $");
37 37
38#include "ssh.h" 38#include "ssh.h"
39#include "ssh1.h" 39#include "ssh1.h"
@@ -1949,22 +1949,6 @@ session_close_by_pid(pid_t pid, int status)
1949 session_close(s); 1949 session_close(s);
1950} 1950}
1951 1951
1952int
1953session_have_children(void)
1954{
1955 int i;
1956
1957 for(i = 0; i < MAX_SESSIONS; i++) {
1958 Session *s = &sessions[i];
1959 if (s->used && s->pid != -1) {
1960 debug("session_have_children: id %d pid %d", i, s->pid);
1961 return 1;
1962 }
1963 }
1964 debug("session_have_children: no more children");
1965 return 0;
1966}
1967
1968/* 1952/*
1969 * this is called when a channel dies before 1953 * this is called when a channel dies before
1970 * the session 'child' itself dies 1954 * the session 'child' itself dies
@@ -1982,15 +1966,29 @@ session_close_by_channel(int id, void *arg)
1982 s->chanid = -1; 1966 s->chanid = -1;
1983 1967
1984 debug("session_close_by_channel: channel %d kill %d", id, s->pid); 1968 debug("session_close_by_channel: channel %d kill %d", id, s->pid);
1985 if (s->pid == 0) { 1969 if (s->pid != 0) {
1986 /* close session immediately */ 1970 /* notify child */
1987 session_close(s); 1971 if (kill(s->pid, SIGHUP) < 0)
1988 } else {
1989 /* notify child, delay session cleanup */
1990 if (kill(s->pid, (s->ttyfd == -1) ? SIGTERM : SIGHUP) < 0)
1991 error("session_close_by_channel: kill %d: %s", 1972 error("session_close_by_channel: kill %d: %s",
1992 s->pid, strerror(errno)); 1973 s->pid, strerror(errno));
1993 } 1974 }
1975 session_close(s);
1976}
1977
1978void
1979session_close_all(void)
1980{
1981 int i;
1982 for(i = 0; i < MAX_SESSIONS; i++) {
1983 Session *s = &sessions[i];
1984 if (s->used) {
1985 if (s->chanid != -1) {
1986 channel_cancel_cleanup(s->chanid);
1987 s->chanid = -1;
1988 }
1989 session_close(s);
1990 }
1991 }
1994} 1992}
1995 1993
1996static char * 1994static char *