public
Description: A process execution library which doesn't suck.
Clone URL: git://github.com/codahale/ropen.git
Why the double-fork? Stop cargo-culting open3 -- it was written by crazy 
people. Or maybe rational people who
did not document their incredibly weird decisions.
codahale (author)
Thu May 15 13:58:07 -0700 2008
commit  da88232070673ae91d2ea7dbc9f9de34891d2eea
tree    ea13e45b375d8b8e62efb8ddde943020583e95f7
parent  0b17a2ade0aa9194a02f0772b99d13c5960e4550
...
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
 
 
 
 
36
37
38
39
40
41
 
42
43
44
...
68
69
70
71
 
72
73
74
...
21
22
23
 
 
 
 
 
 
 
 
 
 
 
 
24
25
26
27
28
29
30
31
32
33
34
35
36
37
...
61
62
63
 
64
65
66
67
0
@@ -21,24 +21,17 @@ class Ropen::Command
0
   def run
0
     initialize_streams
0
     pid = fork do
0
- # child
0
- sub_pid = fork do
0
- # grandchild
0
- @stdin.bind_input(STDIN)
0
- @stdout.bind_output(STDOUT)
0
- @stderr.bind_output(STDERR)
0
- exec(@executable, *@arguments)
0
- end
0
- # TODO: figure out how to pass sub_pid upstream to the grandparent process
0
- exit(0)
0
-# Process.waitpid(sub_pid)
0
-# exit($?.exitstatus)
0
+ @stdin.bind_input(STDIN)
0
+ @stdout.bind_output(STDOUT)
0
+ @stderr.bind_output(STDERR)
0
+ exec(@executable, *@arguments)
0
     end
0
     stdin, stdout, stderr = open_streams(pid)
0
     @stdin_io = stdin
0
     @stdout_events.run(stdout)
0
     @stderr_events.run(stderr)
0
     [@stdout_events, @stderr_events].each { |e| e.finish }
0
+ Process.waitpid(pid)
0
     return @exit_status = $?
0
   ensure
0
     finalize_streams
0
@@ -68,7 +61,7 @@ private
0
     @stdin.close_reader
0
     @stdout.close_writer
0
     @stderr.close_writer
0
- Process.waitpid(pid)
0
+# Process.waitpid(pid)
0
     @stdin.writer.sync = true
0
     return [@stdin.writer, @stdout.reader, @stderr.reader]
0
   end

Comments

    No one has commented yet.