tasks 1.0 → 1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/tasks.rb +22 -2
- metadata +2 -2
data/lib/tasks.rb
CHANGED
@@ -1,8 +1,28 @@
|
|
1
1
|
module Tasks
|
2
2
|
module_function
|
3
3
|
|
4
|
-
|
5
|
-
|
4
|
+
# Tasks.spawn
|
5
|
+
# spawns a new process.
|
6
|
+
#
|
7
|
+
# This code is almost equivalent to the following code:
|
8
|
+
#
|
9
|
+
# def spawn(*cmd)
|
10
|
+
# fork { exec(*cmd) }
|
11
|
+
# end
|
12
|
+
#
|
13
|
+
# But Tasks.spawn doesn't use exec() for avoiding making new process.
|
14
|
+
#
|
15
|
+
# e.g. spawn('sleep 100 | echo') generates the following two processes:
|
16
|
+
# * sh -c 'sleep 100 | echo'
|
17
|
+
# * sleep 10
|
18
|
+
def spawn(cmd)
|
19
|
+
a = IO.popen(cmd)
|
20
|
+
fork do
|
21
|
+
while b = a.gets
|
22
|
+
puts b
|
23
|
+
end
|
24
|
+
end
|
25
|
+
a.pid
|
6
26
|
end
|
7
27
|
|
8
28
|
def love_pact(master, slave, interval = 2)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tasks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: "1.
|
4
|
+
version: "1.1"
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ujihisa
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-01-01 00:00:00
|
12
|
+
date: 2010-01-01 00:00:00 +09:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|