15
15
class SystemCommand < Filter
16
16
def initialize(sh, command, *opts)
17
17
if t = opts.find{|opt| !opt.kind_of?(String) && opt.class}
18
Shell.Fail Error::TypeError, t.class, "String"
18
Shell.Fail Error::TypeError, t.class, "String"
84
84
notify "Job(%id) start imp-pipe.", @shell.debug?
85
85
rs = @shell.record_separator unless rs
89
while l = @pipe_in.gets
96
if !ProcessController::USING_AT_EXIT_WHEN_PROCESS_EXIT and _eop
97
notify("warn: Process finishing...",
98
"wait for Job[%id] to finish pipe importing.",
99
"You can use Shell#transact or Shell#check_point for more safe execution.")
102
notify "job(%id}) close imp-pipe.", @shell.debug?
103
@input_queue.push :EOF
89
while l = @pipe_in.gets
96
if !ProcessController::USING_AT_EXIT_WHEN_PROCESS_EXIT and _eop
97
notify("warn: Process finishing...",
98
"wait for Job[%id] to finish pipe importing.",
99
"You can use Shell#transact or Shell#check_point for more safe execution.")
102
notify "job(%id}) close imp-pipe.", @shell.debug?
103
@input_queue.push :EOF
110
110
notify "job(%id) start exp-pipe.", @shell.debug?
115
ProcessController::block_output_synchronize do
120
rescue Errno::EPIPE, Errno::EIO
123
if !ProcessController::USING_AT_EXIT_WHEN_PROCESS_EXIT and _eop
124
notify("shell: warn: Process finishing...",
125
"wait for Job(%id) to finish pipe exporting.",
126
"You can use Shell#transact or Shell#check_point for more safe execution.")
129
notify "job(%id) close exp-pipe.", @shell.debug?
115
ProcessController::block_output_synchronize do
120
rescue Errno::EPIPE, Errno::EIO
123
if !ProcessController::USING_AT_EXIT_WHEN_PROCESS_EXIT and _eop
124
notify("shell: warn: Process finishing...",
125
"wait for Job(%id) to finish pipe exporting.",
126
"You can use Shell#transact or Shell#check_point for more safe execution.")
129
notify "job(%id) close exp-pipe.", @shell.debug?
135
135
alias super_each each
136
136
def each(rs = nil)
137
137
while (l = @input_queue.pop) != :EOF
143
143
# if you wish to output:
144
# "shell: job(#{@command}:#{@pid}) close pipe-out."
146
# mes: "job(%id) close pipe-out."
144
# "shell: job(#{@command}:#{@pid}) close pipe-out."
146
# mes: "job(%id) close pipe-out."
147
147
# yorn: Boolean(@shell.debug? or @shell.verbose?)
148
148
def notify(*opts, &block)
149
149
@shell.notify(*opts) do |mes|
150
yield mes if iterator?
150
yield mes if iterator?
152
mes.gsub!("%id", "#{@command}:##{@pid}")
153
mes.gsub!("%name", "#{@command}")
154
mes.gsub!("%pid", "#{@pid}")
152
mes.gsub!("%id", "#{@command}:##{@pid}")
153
mes.gsub!("%name", "#{@command}")
154
mes.gsub!("%pid", "#{@pid}")