Edited 'exit' function for pnacl in order to avoid crashes.
authorDjomanix <johan.kayser@viacesi.fr>
Thu, 12 Jun 2014 17:57:15 +0000 (13:57 -0400)
committerDjomanix <johan.kayser@viacesi.fr>
Thu, 12 Jun 2014 19:30:45 +0000 (15:30 -0400)
Signed-off-by: Djomanix <johan.kayser@viacesi.fr>

lib/pnacl.nit

index 8f50fa1..3216b73 100644 (file)
@@ -717,4 +717,21 @@ class PnaclApp
                }
        `}
 end
+
+redef interface Object
+       # Calls 'pthread_exit on current thread
+        fun exit_thread(exit_value: Int) `{
+               pthread_exit((void*) exit_value);
+       `}
+
+       # Redef of exit in order to avoid the module to crash by terminating only the Nit thread.
+       redef fun exit(exit_value: Int)
+       do
+               var dictionary = new PepperDictionary
+               dictionary["exit"] = exit_value
+               app.post_dictionary dictionary
+               exit_thread exit_value
+       end
+end
+
 fun app: PnaclApp do return once new PnaclApp