ku-fpg / hermit-shell

HERMIT with GHCi shell
BSD 3-Clause "New" or "Revised" License
2 stars 0 forks source link

resume fails badly #9

Closed andygill closed 9 years ago

andygill commented 9 years ago
HERMIT> resume
Object (fromList [("params",Array (fromList [])),("method",String "resume")])
Object (fromList [("jsonrpc",String "2.0"),("params",Array (fromList [Object (fromList [("params",Array (fromList [])),("method",String "resume")])])),("method",String "send"),("id",Null)])
(fromList [("jsonrpc",String "2.0"),("params",Array (fromList [Object (fromList [("params",Array (fromList [])),("method",String "resume")])])),("method",String "send"),("id",Null)],Just ("2.0","send",Just (Array (fromList [Object (fromList [("params",Array (fromList [])),("method",String "resume")])])),Just Null))
("external","resume",Object (fromList [("params",Array (fromList [])),("method",String "resume")]))
"sending to internal shell"
("resume",0)
POST /
  Accept: 
  Status: 200 OK 0.003876s
"Jude"
*** Exception: ExitSuccess
HERMIT> Linking Reverse ...
bash-3.2$ bash-3.2$ 
<stdin>: hGetChar: hardware fault (Input/output error)

bash-3.2$ 

Note that ExitSuccess does not quit the ghci session.

andygill commented 9 years ago
% stty sane

fixes the bad abort.

andygill commented 9 years ago

We need to re-think this. We want to support

Making the GHCi shell quit is turning out to be quite hard. Perhaps we should consider :abort and :resume?

ecaustin commented 9 years ago

What would :abort and :resume buy us that the existing methods don't? Aren't user defined ghci commands just aliases to existing methods, or are you considering extending ghci internally?

It would be extremely helpful if we had some notion of the hierarchy of all of these processes and where the propagation of the exit exception stops.

andygill commented 9 years ago

Because :abort can both tell the server to shut down, and the tell GHCi shell to quit. I can't see how to stop GHCi from inside a running Haskell program, in a way that restores the stty properties.

ecaustin commented 9 years ago

I think I'm still not clear on what is shutting down correctly and what isn't.

If it's just the GHCi shell that we spawn in the server callback method, would it help to turn off delegation of SIGINT for the process, not use waitForProcess, and instead manually catch and propagate exit exceptions to control the shutdown behavior?

andygill commented 9 years ago

The exit exception does not propagate to the main ghc thread, unfortunately. I think I have a prototype working, checkin shortly.

andygill commented 9 years ago

Added :resume and :abort.

Or you can use the longhand version, which does the same thing.

HERMIT>resume
HERMIT>^D