Syscall: Don't close the simulator's standard file descriptors.
authorTimothy M. Jones <tjones1@inf.ed.ac.uk>
Thu, 22 Jul 2010 17:47:52 +0000 (18:47 +0100)
committerTimothy M. Jones <tjones1@inf.ed.ac.uk>
Thu, 22 Jul 2010 17:47:52 +0000 (18:47 +0100)
src/sim/syscall_emul.cc

index 4726decc5769aede1ed5d121691f85bbbc0e55b9..7b12700e0b8325e83b736952cda116bfc2813a00 100644 (file)
@@ -186,7 +186,10 @@ closeFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc)
 {
     int index = 0;
     int target_fd = p->getSyscallArg(tc, index);
-    int status = close(p->sim_fd(target_fd));
+    int sim_fd = p->sim_fd(target_fd);
+    int status = 0;
+    if (sim_fd > 2)
+        status = close(sim_fd);
     if (status >= 0)
         p->free_fd(target_fd);
     return status;