diff svr-chansession.c @ 609:306a907d23e7

Avoid segfault when handling childpid race
author Matt Johnston <matt@ucc.asn.au>
date Thu, 31 Mar 2011 14:42:11 +0000
parents 810dfc792ca9
children 818108bf7749 67fbba2c2a85
line wrap: on
line diff
--- a/svr-chansession.c	Fri Mar 18 14:31:07 2011 +0000
+++ b/svr-chansession.c	Thu Mar 31 14:42:11 2011 +0000
@@ -692,6 +692,8 @@
 	ses.maxfd = MAX(ses.maxfd, channel->readfd);
 	ses.maxfd = MAX(ses.maxfd, channel->errfd);
 
+	sleep(1);
+
 	addchildpid(chansess, chansess->pid);
 
 	if (svr_ses.lastexit.exitpid != -1) {
@@ -705,6 +707,7 @@
 				TRACE(("found match for lastexitpid"))
 				svr_ses.childpids[i].chansess->exit = svr_ses.lastexit;
 				svr_ses.lastexit.exitpid = -1;
+				break;
 			}
 		}
 	}