Skip to content

Commit 95bca40

Browse files
committed
Properly fix libedit support
Bug #70 came back because in 8b1a8d6 we started loading the application via Process.spawn rather than via spawning, and therefore the require of the readline library went back to coming after the pgid is set. This time I managed to actually figure out the root cause of the issue. libedit's implementation of rl_initialize() calls tcsetattr(), which causes the kernal to generate a SIGTTOU because we cannot write to the terminal after having set the pgid. The default action of SIGTTOU is to stop the process, which is why it hangs. Therefore the proper solution is to just ignore the SIGTTOU. OMG I am so happy I worked this out.
1 parent dcb896e commit 95bca40

File tree

2 files changed

+1
-4
lines changed

2 files changed

+1
-4
lines changed

lib/spring/application/boot.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
Spring::JSON.load(ENV.delete("SPRING_ORIGINAL_ENV").dup)
66
)
77
Signal.trap("TERM") { app.terminate }
8+
Signal.trap("TTOU", "IGNORE")
89

910
app.preload if ENV.delete("SPRING_PRELOAD") == "1"
1011
app.run

lib/spring/boot.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
require "socket"
22
require "thread"
33

4-
# readline must be required before we setpgid, otherwise the require may hang,
5-
# if readline has been built against libedit. See issue #70.
6-
require "readline"
7-
84
require "spring/configuration"
95
require "spring/env"
106
require "spring/process_title_updater"

0 commit comments

Comments
 (0)