Skip to content
Closed
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
7 changes: 7 additions & 0 deletions lib/overcommit/subprocess.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
3 changes: 1 addition & 2 deletions lib/overcommit/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down