31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
# File 'lib/chef/mixin/command/windows.rb', line 31
def popen4(cmd, args={}, &b)
args[:waitlast] ||= false
Open3.popen3(cmd) do |stdin,stdout,stderr,cid|
if b
if args[:waitlast]
b[cid, stdin, stdout, stderr]
stdin.close_write
else
o = StringIO.new
e = StringIO.new
stdin.close
stdout.sync = true
stderr.sync = true
line = stdout.gets(nil)
if line
o.write(line)
end
line = stderr.gets(nil)
if line
e.write(line)
end
o.rewind
e.rewind
b[cid, stdin, o, e]
end
else
[cid, stdin, stdout, stderr]
end
end
$?
end
|