51件ヒット
[1-51件を表示]
(0.041秒)
種類
- モジュール関数 (21)
- インスタンスメソッド (18)
- 特異メソッド (12)
ライブラリ
- ビルトイン (12)
- shell (6)
-
shell
/ process-controller (6) -
shell
/ system-command (6) - timeout (21)
クラス
- Shell (6)
-
Shell
:: ProcessController (6) -
Shell
:: SystemCommand (6) - Thread (12)
モジュール
- Timeout (21)
キーワード
-
handle
_ interrupt (12) -
kill
_ job (6) - timeout (21)
検索結果
先頭5件
-
Shell
:: SystemCommand # kill(signal) -> Integer (21107.0) -
自身のプロセスにシグナルを送ります。
...signal シグナルを整数かその名前の文字列で指定します。
負の値を持つシグナル(あるいはシグナル名の前に-)を指定すると、
プロセスではなくプロセスグループにシグナルを送ります。
@see Process.#kill... -
Shell
# kill(signal , job) -> Integer (21101.0) -
@todo
@todo
ジョブにシグナルを送ります。
@param signal
@param job -
Shell
:: ProcessController # kill _ job(signal , command) -> Integer (9107.0) -
指定されたコマンドにシグナルを送ります。
...列で指定します。
負の値を持つシグナル(あるいはシグナル名の前に-)を指定すると、
プロセスではなくプロセスグループにシグナルを送ります。
@param command コマンドを指定します。
@see Process.#kill... -
Thread
. handle _ interrupt(hash) { . . . } -> object (106.0) -
スレッドの割り込みのタイミングを引数で指定した内容に変更してブロックを 実行します。
...ad#kill、Signal.#trap(未サポート)、メインスレッドの終了
(メインスレッドが終了すると、他のスレッドも終了されます)を意味します。
@param hash 例外クラスがキー、割り込みのタイミングを指定する
Symbol が値の Hash......t(BarError => :never) {
# FooError and BarError are prohibited.
}
}
==== 例外クラスの継承関係
本メソッドでは引数 hash のキーに指定した例外クラスの全てのサブクラスが
処理の対象になります。
例:
Thread.handle_interrupt(Exception =... -
Timeout
. # timeout(sec , exception _ class = nil) {|i| . . . } -> object (30.0) -
ブロックを sec 秒の期限付きで実行します。 ブロックの実行時間が制限を過ぎたときは例外 Timeout::Error が発生します。
...外部コマンドのタイムアウト
require 'timeout'
# テスト用のシェルをつくる。
File.open("loop.sh", "w"){|fp|
fp.print <<SHELL_EOT
#!/bin/bash
S="scale=10"
M=32767
trap 'echo "$S; $m1/($m1+$m2)*4" | bc ; echo "count = $((m1+m2))" ; exit 0' INT
m1=0
m2=0......let m2++
fi
done
SHELL_EOT
}
File.chmod(0755, "loop.sh")
t = 10 # 10 秒でタイムアウト
begin
pid = nil
com = nil
Timeout.timeout(t) {
# system だととまらない
# system("./loop.sh")
com = IO.popen("./loop.sh")
pid = com.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")... -
Timeout
. # timeout(sec , exception _ class , message) {|i| . . . } -> object (30.0) -
ブロックを sec 秒の期限付きで実行します。 ブロックの実行時間が制限を過ぎたときは例外 Timeout::Error が発生します。
...外部コマンドのタイムアウト
require 'timeout'
# テスト用のシェルをつくる。
File.open("loop.sh", "w"){|fp|
fp.print <<SHELL_EOT
#!/bin/bash
S="scale=10"
M=32767
trap 'echo "$S; $m1/($m1+$m2)*4" | bc ; echo "count = $((m1+m2))" ; exit 0' INT
m1=0
m2=0......let m2++
fi
done
SHELL_EOT
}
File.chmod(0755, "loop.sh")
t = 10 # 10 秒でタイムアウト
begin
pid = nil
com = nil
Timeout.timeout(t) {
# system だととまらない
# system("./loop.sh")
com = IO.popen("./loop.sh")
pid = com.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")...