subprocess 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/subprocess.rb +17 -8
- data/lib/subprocess/version.rb +1 -1
- metadata +2 -2
data/lib/subprocess.rb
CHANGED
@@ -360,9 +360,10 @@ module Subprocess
|
|
360
360
|
# Meanwhile, in the parent process...
|
361
361
|
|
362
362
|
# First, let's close some things we shouldn't have access to
|
363
|
-
|
364
|
-
|
365
|
-
|
363
|
+
@child_stdin.close if our_fd?(opts[:stdin])
|
364
|
+
@child_stdout.close if our_fd?(opts[:stdout])
|
365
|
+
@child_stderr.close if our_fd?(opts[:stderr])
|
366
|
+
control_w.close
|
366
367
|
|
367
368
|
# Any errors during the spawn process? We'll get past this point when the
|
368
369
|
# child execs and the OS closes control_w because of the FD_CLOEXEC
|
@@ -516,17 +517,14 @@ module Subprocess
|
|
516
517
|
# descriptor should appear to the child and to this process, respectively.
|
517
518
|
# "mine" is only non-nil in the case of a pipe (in fact, we just return a
|
518
519
|
# list of length one, since ruby will unpack nils from missing list items).
|
519
|
-
#
|
520
|
-
# If you pass either an IO or an Integer (i.e., a raw file descriptor), a
|
521
|
-
# private copy of it will be made using `#dup`.
|
522
520
|
def parse_fd(fd, mode)
|
523
521
|
fds = case fd
|
524
522
|
when PIPE
|
525
523
|
IO.pipe
|
526
524
|
when IO
|
527
|
-
[fd
|
525
|
+
[fd]
|
528
526
|
when Integer
|
529
|
-
[IO.new(fd, mode)
|
527
|
+
[IO.new(fd, mode)]
|
530
528
|
when String
|
531
529
|
[File.open(fd, mode)]
|
532
530
|
when nil
|
@@ -538,6 +536,17 @@ module Subprocess
|
|
538
536
|
mode == 'r' ? fds : fds.reverse
|
539
537
|
end
|
540
538
|
|
539
|
+
# The pair to parse_fd, returns whether or not the file descriptor was
|
540
|
+
# opened by us (and therefore should be closed by us).
|
541
|
+
def our_fd?(fd)
|
542
|
+
case fd
|
543
|
+
when PIPE, String
|
544
|
+
true
|
545
|
+
else
|
546
|
+
false
|
547
|
+
end
|
548
|
+
end
|
549
|
+
|
541
550
|
def mark_fd_cloexec(fd)
|
542
551
|
io = IO.new(fd)
|
543
552
|
io.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)
|
data/lib/subprocess/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: subprocess
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date: 2014-
|
16
|
+
date: 2014-05-01 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: minitest
|