From 054ed340a319f6c33efc44919bfbfc89b235833f Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Sun, 22 Nov 2015 10:03:35 -0500 Subject: Make daemon mode support sharing of libraries across projects --- src/main.mlton.sml | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) (limited to 'src/main.mlton.sml') diff --git a/src/main.mlton.sml b/src/main.mlton.sml index bfc18e59..7197babf 100644 --- a/src/main.mlton.sml +++ b/src/main.mlton.sml @@ -279,19 +279,25 @@ val () = case CommandLine.arguments () of 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 @@ val () = case CommandLine.arguments () of Posix.IO.close oldStdout; Posix.IO.close oldStderr; + Settings.reset (); MLton.GC.pack (); loop () end @@ -324,8 +331,6 @@ val () = case CommandLine.arguments () of 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 () -- cgit v1.2.3