検索結果
先頭5件
-
Kernel
. # spawn(env , program , *args , options={}) -> Integer (8031.0) -
引数を外部コマンドとして実行しますが、生成した 子プロセスの終了を待ち合わせません。生成した子プロセスのプロセスIDを返します。
...す。
これを用いて、IO.popen で、子プロセスの
stderr と stdout を混ぜる例を以下に示します。
//emlist[][ruby]{
io = IO.popen(["sh", "-c", "echo out; echo err >&2", :err=>[:child, :out]])
p io.read #=> "out\nerr\n
//}
spawn と IO.popen では
デフォルトでは非......= spawn(command, :close_others=>false) # don't close 3,4,5,...
//}
これを利用して spawn を IO.popen のように使うことができます。
//emlist[][ruby]{
# similar to r = IO.popen(command)
r, w = IO.pipe
pid = spawn(command, :out=>w) # r は子プロセスで閉じられる
w.clos......ommand, :close_others=>false) # don't close 3,4,5,... (default)
//}
これを利用して spawn を IO.popen のように使うことができます。
//emlist[][ruby]{
# similar to r = IO.popen(command)
r, w = IO.pipe
pid = spawn(command, :out=>w) # r は子プロセスで閉じられる
w.clos... -
Kernel
. # spawn(program , *args) -> Integer (8031.0) -
引数を外部コマンドとして実行しますが、生成した 子プロセスの終了を待ち合わせません。生成した子プロセスのプロセスIDを返します。
...す。
これを用いて、IO.popen で、子プロセスの
stderr と stdout を混ぜる例を以下に示します。
//emlist[][ruby]{
io = IO.popen(["sh", "-c", "echo out; echo err >&2", :err=>[:child, :out]])
p io.read #=> "out\nerr\n
//}
spawn と IO.popen では
デフォルトでは非......= spawn(command, :close_others=>false) # don't close 3,4,5,...
//}
これを利用して spawn を IO.popen のように使うことができます。
//emlist[][ruby]{
# similar to r = IO.popen(command)
r, w = IO.pipe
pid = spawn(command, :out=>w) # r は子プロセスで閉じられる
w.clos......ommand, :close_others=>false) # don't close 3,4,5,... (default)
//}
これを利用して spawn を IO.popen のように使うことができます。
//emlist[][ruby]{
# similar to r = IO.popen(command)
r, w = IO.pipe
pid = spawn(command, :out=>w) # r は子プロセスで閉じられる
w.clos... -
Kernel
. # open(file , mode _ enc = "r" , perm = 0666) -> IO (8013.0) -
file をオープンして、IO(Fileを含む)クラスのインスタンスを返します。
...の子プロセス
を生成し、その子プロセスとの間のパイプ(IOオブジェクト)を返し
ます。(このときの動作は、IO.popen と同じです。
File.open にはパイプラインを生成する機能はありません)。
Perlと異なりコマンドは常に `|' で始......ョンを整数で指定します。
@raise Errno::EXXX ファイルのオープンに失敗した場合に発生します。
@see File.open,IO.popen,IO.open
=== 第二引数のオープンモード・エンコーディング
文字列("mode" か "mode:ext_enc" か "mode:ext_enc:int_enc" とい... -
Kernel
. # open(file , mode _ enc = "r" , perm = 0666) {|io| . . . } -> object (8013.0) -
file をオープンして、IO(Fileを含む)クラスのインスタンスを返します。
...の子プロセス
を生成し、その子プロセスとの間のパイプ(IOオブジェクト)を返し
ます。(このときの動作は、IO.popen と同じです。
File.open にはパイプラインを生成する機能はありません)。
Perlと異なりコマンドは常に `|' で始......ョンを整数で指定します。
@raise Errno::EXXX ファイルのオープンに失敗した場合に発生します。
@see File.open,IO.popen,IO.open
=== 第二引数のオープンモード・エンコーディング
文字列("mode" か "mode:ext_enc" か "mode:ext_enc:int_enc" とい... -
Kernel
. # exec(env , program , *args , options={}) -> () (8007.0) -
引数で指定されたコマンドを実行します。
...替えて以下を実行
$ ps aux|grep sleep
xxxx 32754 0.0 0.0 2580 468 pts/3 S+ 22:01 0:00 mysleep 600
xxxx 32761 0.0 0.0 2824 792 pts/6 S+ 22:01 0:00 grep sleep
@see Kernel.#system,Kernel.#`,Kernel.#spawn,Kernel.#fork,IO.popen,IO.pipe,Kernel.#open,exec(3)... -
Kernel
. # exec(program , *args , options={}) -> () (8007.0) -
引数で指定されたコマンドを実行します。
...替えて以下を実行
$ ps aux|grep sleep
xxxx 32754 0.0 0.0 2580 468 pts/3 S+ 22:01 0:00 mysleep 600
xxxx 32761 0.0 0.0 2824 792 pts/6 S+ 22:01 0:00 grep sleep
@see Kernel.#system,Kernel.#`,Kernel.#spawn,Kernel.#fork,IO.popen,IO.pipe,Kernel.#open,exec(3)... -
Kernel
. # fork -> Integer | nil (8007.0) -
fork(2) システムコールを使ってプロセスの複製を作 ります。親プロセスでは子プロセスのプロセスIDを、子プロセスでは nil を返します。ブロックを指定して呼び出した場合には、生成し た子プロセスでブロックを評価します。
...puts "parent process. pid: #{Process.pid}, child pid: #{child_pid}"
# => parent process. pid: 79055, child pid: 79602
# 親プロセスでの処理
# ...
# 子プロセスの終了を待って終了。
Process.waitpid(child_pid)
//}
@see IO.popen,IO.pipe,Kernel.#at_exit,Kernel.#exit!, fork(2)... -
Kernel
. # fork { . . . } -> Integer | nil (8007.0) -
fork(2) システムコールを使ってプロセスの複製を作 ります。親プロセスでは子プロセスのプロセスIDを、子プロセスでは nil を返します。ブロックを指定して呼び出した場合には、生成し た子プロセスでブロックを評価します。
...puts "parent process. pid: #{Process.pid}, child pid: #{child_pid}"
# => parent process. pid: 79055, child pid: 79602
# 親プロセスでの処理
# ...
# 子プロセスの終了を待って終了。
Process.waitpid(child_pid)
//}
@see IO.popen,IO.pipe,Kernel.#at_exit,Kernel.#exit!, fork(2)... -
Kernel
. # spawn(command , options={}) -> Integer (8006.0) -
引数を外部コマンドとして実行しますが、生成した 子プロセスの終了を待ち合わせません。生成した子プロセスのプロセスIDを返します。
引数を外部コマンドとして実行しますが、生成した
子プロセスの終了を待ち合わせません。生成した子プロセスのプロセスIDを返します。
=== 引数の解釈
この形式では command が shell のメタ文字
//emlist{
* ? {} [] <> () ~ & | \ $ ; ' ` " \n
//}
を含む場合、shell 経由で実行されます。
そうでなければインタプリタから直接実行されます。
@param command コマンドを文字列で指定します。
@param env 更新する環境変数を表す Hash
@param options オプションパラメータ Hash... -
Kernel
. # spawn(env , command , options={}) -> Integer (8006.0) -
引数を外部コマンドとして実行しますが、生成した 子プロセスの終了を待ち合わせません。生成した子プロセスのプロセスIDを返します。
引数を外部コマンドとして実行しますが、生成した
子プロセスの終了を待ち合わせません。生成した子プロセスのプロセスIDを返します。
=== 引数の解釈
この形式では command が shell のメタ文字
//emlist{
* ? {} [] <> () ~ & | \ $ ; ' ` " \n
//}
を含む場合、shell 経由で実行されます。
そうでなければインタプリタから直接実行されます。
@param command コマンドを文字列で指定します。
@param env 更新する環境変数を表す Hash
@param options オプションパラメータ Hash...