ライブラリ
- ビルトイン (216)
-
bigdecimal
/ math (12) - cmath (24)
- open3 (108)
- pty (24)
- syslog (48)
- timeout (21)
-
win32
/ registry (192)
モジュール
キーワード
- CloseKey (12)
- CreateKey (12)
- DeleteKey (12)
- DeleteValue (12)
- EnumKey (12)
- EnumValue (12)
- FlushKey (12)
- OpenKey (12)
- QueryInfoKey (12)
- QueryValue (12)
- SetValue (12)
- acos (12)
- asin (12)
- check (12)
- cos (12)
- cos! (6)
- detach (12)
- exp (6)
- getpgid (12)
- getpty (12)
- getsid (12)
- kill (12)
- open (24)
- open! (12)
- packdw (12)
- packqw (12)
- pid (12)
- pipe? (12)
- pipeline (12)
-
pipeline
_ r (24) -
pipeline
_ rw (24) -
pipeline
_ start (24) -
pipeline
_ w (24) - ppid (12)
- printf (24)
- reopen (12)
- setpgid (12)
- sin (12)
- sin! (6)
- spawn (12)
- tan! (6)
- timeout (21)
- unpackdw (12)
- unpackqw (12)
- wait (12)
- wait2 (12)
- waitpid (12)
- waitpid2 (12)
検索結果
先頭5件
-
BigMath
. # PI(prec) -> BigDecimal (21120.0) -
円周率を prec で指定した精度で計算します。
...@raise ArgumentError prec に 0 以下が指定された場合に発生します。
//emlist[][ruby]{
require "bigdecimal/math"
puts BigMath::PI(2) #=> 0.31415926535897932384671233672993238432e1
puts BigMath::PI(5) #=> 0.31415926535897932384627534923029509162e1
puts BigMath::PI(10) #=> 0.31415... -
Open3
. # pipeline _ start(*cmds) -> [Thread] (12219.0) -
指定したコマンドのリストをパイプで繋いで順番に実行します。
...それぞれのコマンドは
以下のように String か Array で指定します。
commandline にはコマンド全体(例. "nroff -man")を表す
String を指定します。
options には Hash で指定します。
env には環......名を表す String を指定します。
1、2、3 は shell 経由で実行されます。
(1) commandline
(2) [commandline, options]
(3) [env, commandline, options]
(4) [env, cmdname, arg1, arg2, ..., options]
(5) [env, [cmdname, argv0], arg1, ..., options]
@return ブロック......ッ
ドの配列を返します。
例:
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... -
Open3
. # pipeline _ start(*cmds) {|wait _ thrs| . . . } -> () (12219.0) -
指定したコマンドのリストをパイプで繋いで順番に実行します。
...それぞれのコマンドは
以下のように String か Array で指定します。
commandline にはコマンド全体(例. "nroff -man")を表す
String を指定します。
options には Hash で指定します。
env には環......名を表す String を指定します。
1、2、3 は shell 経由で実行されます。
(1) commandline
(2) [commandline, options]
(3) [env, commandline, options]
(4) [env, cmdname, arg1, arg2, ..., options]
(5) [env, [cmdname, argv0], arg1, ..., options]
@return ブロック......ッ
ドの配列を返します。
例:
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... -
Process
. # waitpid(pid = -1 , flags = 0) -> Integer | nil (9301.0) -
pid で指定される特定の子プロセスの終了を待ち、そのプロセスが 終了した時に pid を返します。 wait2, waitpid2 は子プロセスの pid と終了ステータスを表す Process::Status オブジェクトの配列を返します。 ノンブロッキングモードで子プロセスがまだ終了していない時には nil を返します。
...
pid で指定される特定の子プロセスの終了を待ち、そのプロセスが
終了した時に pid を返します。
wait2, waitpid2 は子プロセスの pid と終了ステータスを表す
Process::Status オブジェクトの配列を返します。
ノンブロッキングモー......セスがまだ終了していない時には
nil を返します。
$? に終了した子プロセスの Process::Status オブジェクトがセットされます。
@param pid 子プロセスのプロセス ID を整数で指定します。
0 以上なら指定されたプロセス ID......ちます。
-1 未満なら pid の絶対値とプロセスグループ ID が同じ任意の子プロセスを待ちます。
@param flags Process モジュールの定数 Process::WNOHANG(ノンブロッキングモード)と
Process::WUNTRACED の論理和を指定します... -
Process
. # waitpid2(pid = -1 , flags = 0) -> [Integer , Process :: Status] | nil (9301.0) -
pid で指定される特定の子プロセスの終了を待ち、そのプロセスが 終了した時に pid を返します。 wait2, waitpid2 は子プロセスの pid と終了ステータスを表す Process::Status オブジェクトの配列を返します。 ノンブロッキングモードで子プロセスがまだ終了していない時には nil を返します。
...
pid で指定される特定の子プロセスの終了を待ち、そのプロセスが
終了した時に pid を返します。
wait2, waitpid2 は子プロセスの pid と終了ステータスを表す
Process::Status オブジェクトの配列を返します。
ノンブロッキングモー......セスがまだ終了していない時には
nil を返します。
$? に終了した子プロセスの Process::Status オブジェクトがセットされます。
@param pid 子プロセスのプロセス ID を整数で指定します。
0 以上なら指定されたプロセス ID......ちます。
-1 未満なら pid の絶対値とプロセスグループ ID が同じ任意の子プロセスを待ちます。
@param flags Process モジュールの定数 Process::WNOHANG(ノンブロッキングモード)と
Process::WUNTRACED の論理和を指定します... -
Timeout
. # timeout(sec , exception _ class = nil) {|i| . . . } -> object (9273.0) -
ブロックを sec 秒の期限付きで実行します。 ブロックの実行時間が制限を過ぎたときは例外 Timeout::Error が発生します。
...c 秒の期限付きで実行します。
ブロックの実行時間が制限を過ぎたときは例外
Timeout::Error が発生します。
exception_class を指定した場合には Timeout::Error の代わりに
その例外が発生します。
ブロックパラメータ i は sec がはい......@param exception_class タイムアウトした時、発生させる例外を指定します.
例 長い計算のタイムアウト
require 'timeout'
def calc_pi(min)
loop do
x = rand
y = rand
x**2 + y**2 < 1.0 ? min[0] += 1 : min[1] += 1
end
end
t = 5
min =......in
Timeout.timeout(t){
calc_pi(min)
}
rescue Timeout::Error
puts "timeout"
end
printf "%d: pi = %f\n", min[0] + min[1], min[0]*4.0/(min[0]+min[1])
#例
#=> 417519: pi = 3.141443
例 独自の例外を発生させるタイムアウト
#!/usr/bin/env ruby
require 'ti......m exception_class タイムアウトした時、発生させる例外を指定します.
@param message エラーメッセージを指定します.省略した場合は
"execution expired" になります.
例 長い計算のタイムアウト
require 'timeout'
def calc_pi(min)......n[0] += 1 : min[1] += 1
end
end
t = 5
min = [ 0, 0]
begin
Timeout.timeout(t){
calc_pi(min)
}
rescue Timeout::Error
puts "timeout"
end
printf "%d: pi = %f\n", min[0] + min[1], min[0]*4.0/(min[0]+min[1])
#例
#=> 417519: pi = 3.141443
例 独自の例外を... -
Timeout
. # timeout(sec , exception _ class , message) {|i| . . . } -> object (9273.0) -
ブロックを sec 秒の期限付きで実行します。 ブロックの実行時間が制限を過ぎたときは例外 Timeout::Error が発生します。
...c 秒の期限付きで実行します。
ブロックの実行時間が制限を過ぎたときは例外
Timeout::Error が発生します。
exception_class を指定した場合には Timeout::Error の代わりに
その例外が発生します。
ブロックパラメータ i は sec がはい......m exception_class タイムアウトした時、発生させる例外を指定します.
@param message エラーメッセージを指定します.省略した場合は
"execution expired" になります.
例 長い計算のタイムアウト
require 'timeout'
def calc_pi(min)......n[0] += 1 : min[1] += 1
end
end
t = 5
min = [ 0, 0]
begin
Timeout.timeout(t){
calc_pi(min)
}
rescue Timeout::Error
puts "timeout"
end
printf "%d: pi = %f\n", min[0] + min[1], min[0]*4.0/(min[0]+min[1])
#例
#=> 417519: pi = 3.141443
例 独自の例外を... -
PTY
. # getpty(command) {|read , write , pid| . . . } -> nil (9201.0) -
擬似 tty を確保し、指定されたコマンドをその擬似 tty の向こうで実行し、配列を返します。
...擬似 tty を確保し、指定されたコマンドをその擬似 tty の向こうで実行し、配列を返します。
プラットフォームに依存しますが、対応していれば、作られたプロセスはセッションリーダーに
なり、その制御端末は作成され......た擬似 tty に設定されます。
@param command 擬似 tty 上で実行するコマンド
@return 返値は3つの要素からなる配列です。最初の要素は擬似 tty から
読み出すための IO オブジェクト、2番目の要素は書きこむための IO オブジ......素は子プロセスのプロセス ID です。
このメソッドがブロック付き呼ばれた場合、これらの要素はブロックパラメータとして渡され、
メソッド自体は nil を返します。
@see Kernel.#spawn, Kernel.#system, IO.popen, signal(2)... -
FileTest
. # pipe?(file) -> bool (9101.0) -
指定したファイルがパイプである時に真を返します。そうでない場合、ファイルが存在しない場合、あるいはシステムコールに失敗した場合などには false を返します。
...。
@param file ファイル名を表す文字列か IO オブジェクトを指定します。
@raise IOError 指定された IO オブジェクト file が既に close されていた場合に発生します。
例:
r, w = IO.pipe
FileTest.pipe?(r) # => true
FileTest.pipe?(w) # => true...