Skip to content

Suspend and Resume on TSTP and CONT signals #361 #514

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Fix binstubs not being replaced when their quoting style was changed (#534)
* Preserve comments right after the shebang line which might include magic comments such as `frozen_string_literal: true'
* Fix binstub failures when Bundler's `BUNDLE_APP_CONFIG` environment variable is present (#545)
* Properly suspend and resume on ctrl-z TSTP and CONT (#361)

## 2.0.2

Expand Down
14 changes: 14 additions & 0 deletions lib/spring/client/run.rb
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ def run_command(client, application)
if pid && !pid.empty?
log "got pid: #{pid}"

suspend_resume_on_tstp_cont(pid)

forward_signals(application)
status = application.read.to_i

Expand All @@ -181,6 +183,18 @@ def queue_signals
end
end

def suspend_resume_on_tstp_cont(pid)
trap("TSTP") {
log "suspended"
Process.kill("STOP", pid.to_i)
Process.kill("STOP", Process.pid)
}
trap("CONT") {
log "resumed"
Process.kill("CONT", pid.to_i)
}
end

def forward_signals(application)
@signal_queue.each { |sig| kill sig, application }

Expand Down