process_starter 1.0.12 → 1.0.13
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/process_starter.rb +11 -5
- metadata +4 -4
data/lib/process_starter.rb
CHANGED
@@ -43,8 +43,9 @@ module ProcessStarter
|
|
43
43
|
# -w = current working directory
|
44
44
|
r = system("psexec -d -w #{Dir.pwd} #{s}")
|
45
45
|
else
|
46
|
-
log "starting using START cmd /c (inherits descriptors (?) -
|
47
|
-
close_io(
|
46
|
+
log "starting using START cmd /c (inherits descriptors (?) - THIS IS BAD, PLEASE DOWNLOAD and COPY PSEXEC TO AVAILABLE 'PATH')"
|
47
|
+
# CANNOT call close_io here, because it will close descriptors in current (parent) process
|
48
|
+
# close_io(true,true)
|
48
49
|
system("start /b cmd /c #{s}")
|
49
50
|
end
|
50
51
|
else
|
@@ -93,6 +94,7 @@ module ProcessStarter
|
|
93
94
|
def self.close_io( do_close=false, debug = false )
|
94
95
|
close_them = []
|
95
96
|
# Make sure all input/output streams are closed
|
97
|
+
puts "close_io: Part I" if debug
|
96
98
|
# Part I: close all IO objects (except for STDIN/STDOUT/STDERR)
|
97
99
|
ObjectSpace.each_object(IO) do |io|
|
98
100
|
unless [STDIN, STDOUT, STDERR].include?(io)
|
@@ -101,6 +103,7 @@ module ProcessStarter
|
|
101
103
|
# puts io.fcntl(Fcntl::F_GETFD) & Fcntl::FD_CLOEXEC
|
102
104
|
if (not io.closed?) and (io.fcntl(Fcntl::F_GETFD) & Fcntl::FD_CLOEXEC) == 0
|
103
105
|
close_them << io.to_i
|
106
|
+
puts "Closing #{io.inspect}" if debug
|
104
107
|
io.close if do_close
|
105
108
|
end
|
106
109
|
rescue ::Exception
|
@@ -108,12 +111,12 @@ module ProcessStarter
|
|
108
111
|
end
|
109
112
|
end
|
110
113
|
# puts close_them.inspect
|
111
|
-
|
114
|
+
|
115
|
+
puts "close_io: Part II" if debug
|
112
116
|
# Make sure all input/output streams are closed
|
113
117
|
# Part II: close all file decriptors (except for STDIN/STDOUT/STDERR)
|
114
118
|
ios = Array.new(8192) {|i| IO.for_fd(i) rescue nil}.compact
|
115
119
|
ios.each do |io|
|
116
|
-
puts "qqq" if debug
|
117
120
|
puts io.to_i if debug
|
118
121
|
next if io.fileno < 3
|
119
122
|
puts "checking flag" if debug
|
@@ -124,7 +127,10 @@ module ProcessStarter
|
|
124
127
|
next if r
|
125
128
|
# puts "adding"
|
126
129
|
close_them << io.to_i
|
127
|
-
|
130
|
+
if do_close
|
131
|
+
puts "Closing #{io.inspect}" if debug
|
132
|
+
io.close ### rescue nil -- DO NOT need to have rescue here, because if we cannot close - it is some kind of exception which need to be tracked
|
133
|
+
end
|
128
134
|
end
|
129
135
|
# puts close_them.inspect
|
130
136
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: process_starter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 13
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 13
|
10
|
+
version: 1.0.13
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Pavel Vasev
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2013-06-13 00:00:00 Z
|
19
19
|
dependencies: []
|
20
20
|
|
21
21
|
description: A gem for Ruby 1.8 to start process in parallel, 1) don't wait for it finish 2) dont inherit io file handles 3) both in windows/linux. Ruby 1.9 dont need it because it has spawn method.
|