comparison mercurial/cmdutil.py @ 10344:9501cde4c034

util: make spawndetached() handle subprocess early terminations The file-based synchronization introduced by e22695b4472f hangs when the child process fails before terminating the handshake, which the previous pipe-based version handled correctly. To fix this, the parent polling loop was fixed to detect premature terminations of the child process.
author Patrick Mezard <pmezard@gmail.com>
date Sat, 06 Feb 2010 16:50:00 +0100
parents 08a0f04b56bd
children 6252852b4332
comparison
equal deleted inserted replaced
10343:b8e3aeb7542c 10344:9501cde4c034
582 del runargs[i] 582 del runargs[i]
583 break 583 break
584 elif runargs[i].startswith('--cwd'): 584 elif runargs[i].startswith('--cwd'):
585 del runargs[i:i + 2] 585 del runargs[i:i + 2]
586 break 586 break
587 pid = util.spawndetached(runargs) 587 def condfn():
588 while os.path.exists(lockpath): 588 return not os.path.exists(lockpath)
589 time.sleep(0.1) 589 pid = util.rundetached(runargs, condfn)
590 if pid < 0:
591 raise util.Abort(_('child process failed to start'))
590 finally: 592 finally:
591 try: 593 try:
592 os.unlink(lockpath) 594 os.unlink(lockpath)
593 except OSError, e: 595 except OSError, e:
594 if e.errno != errno.ENOENT: 596 if e.errno != errno.ENOENT: