]> git.deb.at Git - pkg/netris.git/blobdiff - robot.c
Imported Debian patch 0.52-2
[pkg/netris.git] / robot.c
diff --git a/robot.c b/robot.c
index 23875a3bd4b9984bf0c1815e95e7970c5f8318e2..cbd5cb22902a0a8cf91f9ea54e1584b20d2e869d 100644 (file)
--- a/robot.c
+++ b/robot.c
@@ -35,7 +35,7 @@ static EventGenRec robotGen =
                { NULL, 0, FT_read, -1, RobotGenFunc, EM_robot };
 
 static int robotProcess;
-static FILE *toRobot;
+static FILE *toRobot = NULL;
 static int toRobotFd, fromRobotFd;
 
 static char robotBuf[128];
@@ -112,10 +112,13 @@ ExtFunc void RobotTimeStamp(void)
 ExtFunc void CloseRobot(void)
 {
        RemoveEventGen(&robotGen);
-       if (robotProcess > 0)
-               RobotCmd(1, "Exit\n");
-       fclose(toRobot);
-       close(fromRobotFd);
+       if(toRobot) {
+               if (robotProcess > 0)
+                       RobotCmd(1, "Exit\n");
+               fclose(toRobot);
+               close(fromRobotFd);
+               toRobot = NULL;
+       }
 }
 
 static MyEventType RobotGenFunc(EventGenRec *gen, MyEvent *event)