Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

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

Closed
inkytonik opened this Issue · 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

Platform?

@wuub wuub was assigned
@inkytonik

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

@wuub
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.

@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

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 referenced this issue from a commit
@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

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
@inkytonik

Sounds good to me. Thx.

@wuub wuub reopened this
@wuub
Owner

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

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