Skip to content
This repository

Scala REPL doesn't die when tab is closed #17

Closed
inkytonik opened this Issue February 23, 2012 · 9 comments

2 participants

Tony Sloane Wojciech Bederski
Tony Sloane

If I create a Scala REPL via Tools | SublimeREPL | Scala, all is well. However, if I close the tab containing the REPL, the Scala process is left running.

I've checked a few of the other REPLs and they all seem to be dying properly when the tab is closed, so this behaviour appears to be specific to the Scala one.

Wojciech Bederski
Owner

Platform?

Tony Sloane

Oops, sorry. This is on OS X 10.7.3 with Scala 2.9.1.final.

Wojciech Bederski
Owner

Hmm. I know there is a problem with that on Windows for repls launched using .bat-s. SublimeREPL sends SIGTERM when tab is closed, and the cmd.exe that was running that bat dies correctly but the process itself is left running.
It should not happen on osx though... I'll take a look.

Tony Sloane

Thanks. I just confirmed that the shell process dies, but its subprocess doesn't.

Seems to be a known issue on OS X:

http://superuser.com/questions/99789/when-a-python-process-is-killed-on-osx-why-doesnt-it-kill-the-child-processes

The main suggestion is to kill the process group, rather than just the top process.

Wojciech Bederski
Owner

Adding
preexec_fn=os.setsid

to subprocess.Popen() should fix this on oxs/linux. During SublimePTY development I noticed that it's crucial for correct signal propagation down the process tree.
I think I'll also add a "soft_kill" i.e. sending a configurable quit command to subprocess just before SIGTERM.

Tony Sloane

I am seeing the same behaviour if I add that to arg to the subprocess.Popen call.

Having a configurable quit command seems to be a flexible approach.

Wojciech Bederski wuub referenced this issue from a commit February 26, 2012
Wojciech Bederski add soft_quit option to suprocess repl
soft_quit is always sent to preocess just before termination, 'fixes'
issue #17 in a platform independent way w/o lost of hacks
d6a25be
Wojciech Bederski wuub closed this February 26, 2012
Wojciech Bederski
Owner

I decided to go with the soft_quit solution, it is not 100% effective, but at least cross platform and easy to understand

Tony Sloane

Sounds good to me. Thx.

Wojciech Bederski wuub reopened this April 26, 2012
Wojciech Bederski
Owner
wuub commented April 26, 2012

note to self: Check if killableprocess fixes this on OSX (if .killpg is used)

Wojciech Bederski wuub closed this May 07, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.