diff --git a/lib/overcommit/subprocess.rb b/lib/overcommit/subprocess.rb index 9f556659..74edd172 100644 --- a/lib/overcommit/subprocess.rb +++ b/lib/overcommit/subprocess.rb @@ -29,6 +29,13 @@ def spawn(args) Result.new(process.exit_code, out.read, err.read) end + # Spawns a new process in the background using the given array of + # arguments (the first element is the command). + def spawn_detached(args) + # Dissociate process from parent's input/output streams + Process.detach(Process.spawn({}, *args, [:in, :out, :err] => '/dev/null')) + end + private # @param process [ChildProcess] diff --git a/lib/overcommit/utils.rb b/lib/overcommit/utils.rb index 540937f3..e51ce93a 100644 --- a/lib/overcommit/utils.rb +++ b/lib/overcommit/utils.rb @@ -131,8 +131,7 @@ def execute_in_background(args) 'Cannot pipe commands with the `execute_in_background` helper' end - # Dissociate process from parent's input/output streams - Process.detach(Process.spawn({}, *args, [:in, :out, :err] => '/dev/null')) + Subprocess.spawn_detached(args) end # Calls a block of code with a modified set of environment variables,