gnome-games r7622 - in branches/gnome-2-22/glchess: . src/lib
- From: rancell svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-games r7622 - in branches/gnome-2-22/glchess: . src/lib
- Date: Sun, 13 Apr 2008 08:55:01 +0100 (BST)
Author: rancell
Date: Sun Apr 13 08:55:01 2008
New Revision: 7622
URL: http://svn.gnome.org/viewvc/gnome-games?rev=7622&view=rev
Log:
Check PID returned on SIGCHLD (Bug #527686)
Modified:
branches/gnome-2-22/glchess/ChangeLog
branches/gnome-2-22/glchess/src/lib/ai.py
Modified: branches/gnome-2-22/glchess/src/lib/ai.py
==============================================================================
--- branches/gnome-2-22/glchess/src/lib/ai.py (original)
+++ branches/gnome-2-22/glchess/src/lib/ai.py Sun Apr 13 08:55:01 2008
@@ -230,29 +230,31 @@
self.__fromEngineFd = fromManagerOutput
# Catch if the child dies
+ self.__pid = None
def cDied(sig, stackFrame):
try:
- os.waitpid(-1, os.WNOHANG)
+ (pid, status) = os.waitpid(-1, os.WNOHANG)
except OSError:
pass
-
- # If unexpected then AI has died
- if self.__fromEngineFd != None:
- print 'Monitor died'
- self.die()
+ else:
+ # If unexpected then AI has died
+ if pid == self.__pid and self.__fromEngineFd != None:
+ print 'Monitor died'
+ self.die()
signal.signal(signal.SIGCHLD, cDied)
# Fork off a child process to manage the engine
- if os.fork() == 0:
+ self.__pid = os.fork()
+ if self.__pid == 0:
os.close(toManagerInput)
os.close(fromManagerOutput)
self._runMonitor(fromManagerInput, toManagerOutput)
os.close(toManagerOutput)
os.close(fromManagerInput)
os._exit(0)
- else:
- os.close(toManagerOutput)
- os.close(fromManagerInput)
+
+ os.close(toManagerOutput)
+ os.close(fromManagerInput)
if profile.protocol == CECP:
self.connection = CECPConnection(self)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]