changeset 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 4fbf9a7556ed
children 3c5f631358a0
files svr-chansession.c
diffstat 1 files changed, 3 insertions(+), 0 deletions(-) [+]
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;
 			}
 		}
 	}