diff src/main.mlton.sml @ 2192:fb113569519e

Make daemon mode support sharing of libraries across projects
author Adam Chlipala <adam@chlipala.net>
date Sun, 22 Nov 2015 10:03:35 -0500
parents 057b08253a75
children 6fb9232ade99
line wrap: on
line diff
--- a/src/main.mlton.sml	Sun Nov 01 17:02:16 2015 -0500
+++ b/src/main.mlton.sml	Sun Nov 22 10:03:35 2015 -0500
@@ -279,19 +279,25 @@
                                           in
                                               case cmd of
                                                   "" =>
-                                                  let
-                                                      val success = (oneRun (rev args))
-                                                          handle ex => (print "unhandled exception:\n";
-                                                                        print (General.exnMessage ex ^ "\n");
-                                                                        OS.Process.failure)
-                                                  in
-                                                      TextIO.flushOut TextIO.stdOut;
-                                                      TextIO.flushOut TextIO.stdErr;
-                                                      send (sock, if OS.Process.isSuccess success then
-                                                                      "\001"
-                                                                  else
-                                                                      "\002")
-                                                  end
+                                                  (case args of
+                                                       ["stop", "daemon"] =>
+                                                       (((Socket.close listen;
+                                                          OS.FileSys.remove socket) handle OS.SysErr _ => ());
+                                                        OS.Process.exit OS.Process.success)
+                                                     | _ =>
+                                                       let
+                                                           val success = (oneRun (rev args))
+                                                               handle ex => (print "unhandled exception:\n";
+                                                                             print (General.exnMessage ex ^ "\n");
+                                                                             OS.Process.failure)
+                                                       in
+                                                           TextIO.flushOut TextIO.stdOut;
+                                                           TextIO.flushOut TextIO.stdErr;
+                                                           send (sock, if OS.Process.isSuccess success then
+                                                                           "\001"
+                                                                       else
+                                                                           "\002")
+                                                       end)
                                                 | _ => loop' (rest, cmd :: args)
                                           end
                                   end handle OS.SysErr _ => ()
@@ -315,6 +321,7 @@
                               Posix.IO.close oldStdout;
                               Posix.IO.close oldStderr;
 
+                              Settings.reset ();
                               MLton.GC.pack ();
                               loop ()
                           end
@@ -324,8 +331,6 @@
                       Socket.listen (listen, 1);
                       loop ()
                   end)
-           | ["daemon", "stop"] =>
-	     (OS.FileSys.remove socket handle OS.SysErr _ => OS.Process.exit OS.Process.success) 
            | args =>
              let
                  val sock = UnixSock.Strm.socket ()