-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #56 from Shopify/close-fds
[Experimental] Pitchfork::Info.close_all_fds!
- Loading branch information
Showing
10 changed files
with
105 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,10 @@ def at_fork | |
nil | ||
end | ||
|
||
def to_io | ||
@file | ||
end | ||
|
||
def unlink | ||
File.unlink(@file.path) | ||
rescue Errno::ENOENT | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'test_helper' | ||
|
||
class TestInfo < Pitchfork::Test | ||
def test_close_all_ios_except_marked_ones | ||
r, w = IO.pipe | ||
|
||
Pitchfork::Info.keep_io(w) | ||
|
||
pid = Process.fork do | ||
Pitchfork::Info.close_all_ios! | ||
|
||
w.write(Marshal.dump([ | ||
$stdin.closed?, | ||
$stdout.closed?, | ||
$stderr.closed?, | ||
r.closed?, | ||
w.closed? | ||
])) | ||
Process.exit!(0) | ||
end | ||
|
||
_, status = Process.wait2(pid) | ||
assert_predicate status, :success? | ||
|
||
info = Marshal.load(r) | ||
|
||
assert_equal([ | ||
false, # $stdin | ||
false, # $stdout | ||
false, # $stderr | ||
true, # r | ||
false, # w | ||
], info) | ||
end | ||
end |