クラス
- Thread (88)
キーワード
-
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (11) - Thread (11)
- backtrace (11)
- exit (11)
-
handle
_ interrupt (11) - irb (11)
- kill (22)
-
pipeline
_ start (22) -
rb
_ thread _ kill (11) -
rb
_ thread _ s _ kill (11) -
ruby 1
. 8 . 4 feature (11) - status (11)
- terminate (11)
- timeout (19)
- value (11)
- スレッド (11)
- セキュリティモデル (2)
- 終了処理 (11)
検索結果
先頭2件
-
Timeout
. # timeout(sec , exception _ class , message) {|i| . . . } -> object (12.0) -
ブロックを sec 秒の期限付きで実行します。 ブロックの実行時間が制限を過ぎたときは例外 Timeout::Error が発生します。
...out(5, MYError) {
sleep(30)
}
rescue MYError => err
puts "MYError"
puts err
end
=== 注意
timeout による割り込みは Thread によって実現されています。
C 言語レベルで実装され、
Ruby のスレッドが割り込めない処理に対して timeout.......pid
while line = com.gets
print line
end
}
rescue Timeout::Error => err
puts "timeout: shell execution."
Process.kill('SIGINT', pid)
printf "[result]\t%s", com.read
com.close unless com.nil?
end
#止まっているか確認する。
#system("ps au")... -
Open3
. # pipeline _ start(*cmds) {|wait _ thrs| . . . } -> () (7.0) -
指定したコマンドのリストをパイプで繋いで順番に実行します。
...ッ
ドの配列を返します。
例:
require "open3"
# xeyesを10秒だけ実行する。
Open3.pipeline_start("xeyes") {|ts|
sleep 10
t = ts[0]
Process.kill("TERM", t.pid)
p t.value #=> #<Process::Status: pid 911 SIGTERM (signal 15)>
}
@see Open3.#popen3...