process_starter 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/process_starter.rb +8 -6
- metadata +4 -4
data/lib/process_starter.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# 2012 (c) LineAct / www.lineact.com
|
2
2
|
|
3
|
-
require 'rubygems'
|
3
|
+
require 'rubygems'
|
4
4
|
require 'fcntl'
|
5
|
-
|
6
|
-
# https://github.com/rtomayko/posix-spawn
|
5
|
+
|
6
|
+
# https://github.com/rtomayko/posix-spawn
|
7
7
|
begin; require( 'posix/spawn' ) ; rescue LoadError ; end
|
8
8
|
|
9
9
|
module ProcessStarter
|
@@ -53,6 +53,8 @@ module ProcessStarter
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
+
# find all opened io descriptors in current process
|
57
|
+
# without FD_CLOEXEC flag (auto close on exec/system/spawn)
|
56
58
|
# based on close_io from: http://daemons.rubyforge.org/Daemonize.html
|
57
59
|
def self.close_io( do_close=false, debug = false )
|
58
60
|
close_them = []
|
@@ -81,11 +83,11 @@ module ProcessStarter
|
|
81
83
|
puts io.to_i if debug
|
82
84
|
next if io.fileno < 3
|
83
85
|
puts "checking flag" if debug
|
84
|
-
r = begin; io.fcntl(Fcntl::F_GETFD) & Fcntl::FD_CLOEXEC != 0 rescue false; end
|
85
|
-
puts if debug
|
86
|
+
r = begin; io.fcntl(Fcntl::F_GETFD) & Fcntl::FD_CLOEXEC != 0 rescue false; end
|
87
|
+
puts if debug
|
86
88
|
# puts io.fcntl(Fcntl::F_GETFD) & Fcntl::FD_CLOEXEC
|
87
89
|
# next if (io.fcntl(Fcntl::F_GETFD) & Fcntl::FD_CLOEXEC != 0)
|
88
|
-
next if r
|
90
|
+
next if r
|
89
91
|
# puts "adding"
|
90
92
|
close_them << io.to_i
|
91
93
|
io.close if do_close
|
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: 17
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 3
|
10
|
+
version: 1.0.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Pavel Vasev
|
@@ -19,7 +19,7 @@ date: 2012-09-24 00:00:00 +06:00
|
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
22
|
-
description: A gem to start process in parallel
|
22
|
+
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.
|
23
23
|
email: pavel.vasev@gmail.com
|
24
24
|
executables: []
|
25
25
|
|