Skip to content

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

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

2 participants

@inkytonik

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.

@wuub
Owner
wuub commented Feb 23, 2012

Platform?

@wuub wuub was assigned Feb 23, 2012
@inkytonik

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

@wuub
Owner
wuub commented Feb 23, 2012

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.

@inkytonik

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.

@wuub
Owner
wuub commented Feb 23, 2012

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.

@inkytonik

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.

@wuub wuub added a commit that referenced this issue Feb 26, 2012
@wuub 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
@wuub
Owner
wuub commented Feb 26, 2012

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

@wuub wuub closed this Feb 26, 2012
@inkytonik

Sounds good to me. Thx.

@wuub wuub reopened this Apr 26, 2012
@wuub
Owner
wuub commented Apr 26, 2012

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

@wuub wuub closed this May 7, 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.