comparison svr-chansession.c @ 416:a01c0c8e543a channel-fix

Improve behaviour when flushing out after a process has exited.
author Matt Johnston <matt@ucc.asn.au>
date Fri, 09 Feb 2007 10:43:16 +0000
parents 173a5f89666c
children b2b67cfcd66e
comparison
equal deleted inserted replaced
415:8b9aba1d5fa4 416:a01c0c8e543a
118 #endif 118 #endif
119 } else { 119 } else {
120 /* we use this to determine how pid exited */ 120 /* we use this to determine how pid exited */
121 exit->exitsignal = -1; 121 exit->exitsignal = -1;
122 } 122 }
123 } 123
124 124 /* Make sure that the main select() loop wakes up */
125 125 while (1) {
126 /* EAGAIN means the pipe's full, so don't need to write anything */
127 /* isserver is just a random byte to write */
128 if (write(ses.signal_pipe[1], &ses.isserver, 1) == 1 || errno == EAGAIN) {
129 break;
130 }
131 if (errno == EINTR) {
132 continue;
133 }
134 dropbear_exit("error writing signal pipe");
135 }
136 }
137
126 sa_chld.sa_handler = sesssigchild_handler; 138 sa_chld.sa_handler = sesssigchild_handler;
127 sa_chld.sa_flags = SA_NOCLDSTOP; 139 sa_chld.sa_flags = SA_NOCLDSTOP;
128 sigaction(SIGCHLD, &sa_chld, NULL); 140 sigaction(SIGCHLD, &sa_chld, NULL);
129 TRACE(("leave sigchld handler")) 141 TRACE(("leave sigchld handler"))
130 } 142 }
242 254
243 struct ChanSess *chansess; 255 struct ChanSess *chansess;
244 unsigned int i; 256 unsigned int i;
245 struct logininfo *li; 257 struct logininfo *li;
246 258
259 TRACE(("enter closechansess"))
260
247 chansess = (struct ChanSess*)channel->typedata; 261 chansess = (struct ChanSess*)channel->typedata;
248 262
249 send_exitsignalstatus(channel);
250
251 TRACE(("enter closechansess"))
252 if (chansess == NULL) { 263 if (chansess == NULL) {
253 TRACE(("leave closechansess: chansess == NULL")) 264 TRACE(("leave closechansess: chansess == NULL"))
254 return; 265 return;
255 } 266 }
267
268 send_exitsignalstatus(channel);
256 269
257 m_free(chansess->cmd); 270 m_free(chansess->cmd);
258 m_free(chansess->term); 271 m_free(chansess->term);
259 272
260 if (chansess->tty) { 273 if (chansess->tty) {