種類
- 特異メソッド (176)
- モジュール関数 (66)
- インスタンスメソッド (11)
- 文書 (2)
ライブラリ
- ビルトイン (253)
検索結果
先頭5件
-
Kernel
. # fork -> Integer | nil (18354.0) -
fork(2) システムコールを使ってプロセスの複製を作 ります。親プロセスでは子プロセスのプロセスIDを、子プロセスでは nil を返します。ブロックを指定して呼び出した場合には、生成し た子プロセスでブロックを評価します。
...
fork(2) システムコールを使ってプロセスの複製を作
ります。親プロセスでは子プロセスのプロセスIDを、子プロセスでは
nil を返します。ブロックを指定して呼び出した場合には、生成し
た子プロセスでブロックを評価しま......
fork 前に STDOUT と STDERR を IO#flush します。
@raise NotImplementedError 実行環境がこのメソッドに対応していないとき発生します。
//emlist[ブロックを指定しなかった場合][ruby]{
if child_pid = fork
puts "parent process. pid: #{Process.pid}, child......pid: #{child_pid}"
# => parent process. pid: 81060, child pid: 81329
# 親プロセスでの処理
# ...
# 子プロセスの終了を待って終了。
Process.waitpid(child_pid)
else
puts "child process. pid: #{Process.pid}"
# => child process. pid: 81329
# 子プロセスでの... -
Kernel
. # fork { . . . } -> Integer | nil (18354.0) -
fork(2) システムコールを使ってプロセスの複製を作 ります。親プロセスでは子プロセスのプロセスIDを、子プロセスでは nil を返します。ブロックを指定して呼び出した場合には、生成し た子プロセスでブロックを評価します。
...
fork(2) システムコールを使ってプロセスの複製を作
ります。親プロセスでは子プロセスのプロセスIDを、子プロセスでは
nil を返します。ブロックを指定して呼び出した場合には、生成し
た子プロセスでブロックを評価しま......
fork 前に STDOUT と STDERR を IO#flush します。
@raise NotImplementedError 実行環境がこのメソッドに対応していないとき発生します。
//emlist[ブロックを指定しなかった場合][ruby]{
if child_pid = fork
puts "parent process. pid: #{Process.pid}, child......pid: #{child_pid}"
# => parent process. pid: 81060, child pid: 81329
# 親プロセスでの処理
# ...
# 子プロセスの終了を待って終了。
Process.waitpid(child_pid)
else
puts "child process. pid: #{Process.pid}"
# => child process. pid: 81329
# 子プロセスでの... -
Thread
. fork(*arg) {|*arg| . . . } -> Thread (18243.0) -
スレッドを生成して、ブロックの評価を開始します。 生成したスレッドを返します。
...w メソッドと違い initialize メソッドを呼びません。
@param arg 引数 arg はそのままブロックに渡されます。スレッドの開始と同時にその
スレッド固有のローカル変数に値を渡すために使用します。
@raise ThreadError 現在......ードは間違いです。スレッドの実行が開始される前に
変数 i が書き変わる可能性があるからです。
for i in 1..5
Thread.start { p i }
end
上の例は以下のように書き直すべきです。
for i in 1..5
Thread.start(i) {|t| p t }
end... -
Kernel
. # at _ exit { . . . } -> Proc (6266.0) -
与えられたブロックをインタプリタ終了時に実行します。
..._exitがメソッドである点を除けば、END ブロックによる終了
処理の登録と同等です。登録した処理を取り消すことはできません。
spec/terminateも参照してください。
@return 登録した処理を Proc オブジェクトで返します。
//emlist......[例][ruby]{
3.times do |i|
at_exit{puts "at_exit#{i}"}
end
END{puts "END"}
at_exit{puts "at_exit"}
puts "main_end"
#=> main_end
# at_exit
# END
# at_exit2
# at_exit1
# at_exit0
//}
@see d:spec/control#END,Kernel.#exit!,Kernel.#fork... -
Kernel
. # exit!(status = false) -> () (6230.0) -
Rubyプログラムの実行を即座に終了します。 status として整数が与えられた場合、その値を Ruby コマンドの終了ステータスとします。 デフォルトの終了ステータスは 1 です。
...たとみなされます。この値はCレベルの定数
EXIT_SUCCESS、EXIT_FAILURE の値なので、正確には環境依存です。
exit! は exit とは違って、例外処理などは一切行ないませ
ん。 Kernel.#fork の後、子プロセスを終了させる時などに用
いら......す。
//emlist[例][ruby]{
STDOUT.sync = true #表示前に終了しないようにする
puts 'start'
begin
puts 'start1...'
exit!
ensure
puts 'end1...' #実行されない
end
puts 'end' #実行されない
#=> start
# start1...
#終了ステータス:1
//}
@see Kernel.#exit,Kernel.#ab......ort,Kernel.#at_exit,Kernel.#fork... -
IO
. popen("-" , mode = "r" , opt={}) -> IO (3231.0) -
第一引数に文字列 "-" が指定された時、fork(2) を 行い子プロセスの標準入出力との間にパイプラインを確立します。 親プロセスでは IO オブジェクトを返し、子プロセスでは nil を返します。
...字列 "-" が指定された時、fork(2) を
行い子プロセスの標準入出力との間にパイプラインを確立します。
親プロセスでは IO オブジェクトを返し、子プロセスでは
nil を返します。
io = IO.popen("-", "r+")
if io # parent
io.puts "foo......"
p io.gets # => "child output: foo\n"
io.close
else # child
s = gets
print "child output: " + s
exit
end
ブロックを与えられた場合、親プロセスでは生成した IO オブジェクトを引数に
ブロックを実行し、その結果......す。
子プロセスでは nil を引数にブロックを実行し終了します。
p IO.popen("-", "r+") {|io|
if io # parent
io.puts "foo"
io.gets
else # child
s = gets
puts "child output: " + s
end
}
# => "child output: foo\n"
opt ではエ... -
IO
. popen("-" , mode = "r" , opt={}) {|io| . . . } -> object (3231.0) -
第一引数に文字列 "-" が指定された時、fork(2) を 行い子プロセスの標準入出力との間にパイプラインを確立します。 親プロセスでは IO オブジェクトを返し、子プロセスでは nil を返します。
...字列 "-" が指定された時、fork(2) を
行い子プロセスの標準入出力との間にパイプラインを確立します。
親プロセスでは IO オブジェクトを返し、子プロセスでは
nil を返します。
io = IO.popen("-", "r+")
if io # parent
io.puts "foo......"
p io.gets # => "child output: foo\n"
io.close
else # child
s = gets
print "child output: " + s
exit
end
ブロックを与えられた場合、親プロセスでは生成した IO オブジェクトを引数に
ブロックを実行し、その結果......す。
子プロセスでは nil を引数にブロックを実行し終了します。
p IO.popen("-", "r+") {|io|
if io # parent
io.puts "foo"
io.gets
else # child
s = gets
puts "child output: " + s
end
}
# => "child output: foo\n"
opt ではエ... -
IO
. popen(env , "-" , mode = "r" , opt={}) -> IO (3231.0) -
第一引数に文字列 "-" が指定された時、fork(2) を 行い子プロセスの標準入出力との間にパイプラインを確立します。 親プロセスでは IO オブジェクトを返し、子プロセスでは nil を返します。
...字列 "-" が指定された時、fork(2) を
行い子プロセスの標準入出力との間にパイプラインを確立します。
親プロセスでは IO オブジェクトを返し、子プロセスでは
nil を返します。
io = IO.popen("-", "r+")
if io # parent
io.puts "foo......"
p io.gets # => "child output: foo\n"
io.close
else # child
s = gets
print "child output: " + s
exit
end
ブロックを与えられた場合、親プロセスでは生成した IO オブジェクトを引数に
ブロックを実行し、その結果......す。
子プロセスでは nil を引数にブロックを実行し終了します。
p IO.popen("-", "r+") {|io|
if io # parent
io.puts "foo"
io.gets
else # child
s = gets
puts "child output: " + s
end
}
# => "child output: foo\n"
opt ではエ... -
IO
. popen(env , "-" , mode = "r" , opt={}) {|io| . . . } -> object (3231.0) -
第一引数に文字列 "-" が指定された時、fork(2) を 行い子プロセスの標準入出力との間にパイプラインを確立します。 親プロセスでは IO オブジェクトを返し、子プロセスでは nil を返します。
...字列 "-" が指定された時、fork(2) を
行い子プロセスの標準入出力との間にパイプラインを確立します。
親プロセスでは IO オブジェクトを返し、子プロセスでは
nil を返します。
io = IO.popen("-", "r+")
if io # parent
io.puts "foo......"
p io.gets # => "child output: foo\n"
io.close
else # child
s = gets
print "child output: " + s
exit
end
ブロックを与えられた場合、親プロセスでは生成した IO オブジェクトを引数に
ブロックを実行し、その結果......す。
子プロセスでは nil を引数にブロックを実行し終了します。
p IO.popen("-", "r+") {|io|
if io # parent
io.puts "foo"
io.gets
else # child
s = gets
puts "child output: " + s
end
}
# => "child output: foo\n"
opt ではエ... -
IO
. popen([env = {} , [cmdname , arg0] , *args , execopt={}] , mode = "r" , opt={}) -> IO (3221.0) -
サブプロセスを実行し、そのプロセスの標準入出力 との間にパイプラインを確立します。生成したパイプを IO オブジェクトとして返します。
...出力
との間にパイプラインを確立します。生成したパイプを IO オブジェクトとして返します。
p io = IO.popen("cat", "r+") # => #<IO:fd 4>
io.puts "foo"
io.close_write
p io.gets # => "foo\n"
サブプロセスを指定する方法は2......生成した IO オブジェクトを引数にブ
ロックを実行し、ブロックの実行結果を返します。ブロックの実行後、生成したパイ
プは自動的にクローズされます。
p IO.popen("cat", "r+") {|io|
io.puts "foo"
io.close_write
io.gets
}
#......ョンや、パイプ IO オブジェクトの属性(エンコーディングや
読み書き能力)を指定することができます。
プロセス起動のためのオプションは Kernel.#spawn と、
パイプオブジェクトの属性の指定のオプションは IO.new と共通です...