From 2303d0fd09306271cdc447ca164471be4e32e24a Mon Sep 17 00:00:00 2001 From: Matt Johnston Date: Thu, 31 Mar 2011 14:42:11 +0000 Subject: [PATCH] Avoid segfault when handling childpid race --HG-- extra : convert_revision : 8845727a7e2b096015dbb76d8f3df13c9acee7da --- svr-chansession.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/svr-chansession.c b/svr-chansession.c index a914f25..0b3e833 100644 --- a/svr-chansession.c +++ b/svr-chansession.c @@ -692,6 +692,8 @@ static int noptycommand(struct Channel *channel, struct ChanSess *chansess) { 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 @@ static int noptycommand(struct Channel *channel, struct ChanSess *chansess) { TRACE(("found match for lastexitpid")) svr_ses.childpids[i].chansess->exit = svr_ses.lastexit; svr_ses.lastexit.exitpid = -1; + break; } } }