spring icon indicating copy to clipboard operation
spring copied to clipboard

Different exit code for SIGKILL'ed processes with Spring

Open noizwaves opened this issue 3 years ago • 0 comments

With Spring enabled, a Ruby command interrupted by a signal exits with a different exit code compared to that same command run with Spring disabled.

This issue was detected in our containerized development environments, which run inside of Docker. Because Docker enforces memory constraints by OOM'ing and SIGKILL'ing offending processes. The differing behavior can be observed in an application (Ruby 2.7.5, Rails 7.0.2.4, Spring 4.0.0) when forcing an OOM error:

Spring enabled:

$ bin/rails runner "arr = []; while true do; arr.push(1); end"
Running via Spring preloader in process 242
$ echo $?
0

Spring disabled:

$ DISABLE_SPRING=1 bin/rails runner "arr = []; while true do; arr.push(1); end"
Killed
$ echo $?
137

It looks like the status.exitstatus returned by Process.wait2 is nil for signaled processes, and the conversion to the corresponding unix/POSIX exit code for that signal is not done implicitly. exitstatus is returned directly by terminated processes here.

Could this conversion of signal to exit code be added?

noizwaves avatar May 20 '22 15:05 noizwaves