種類
- モジュール関数 (132)
- インスタンスメソッド (22)
検索結果
先頭5件
-
Kernel
# xpopen(command , *mode) -> IO (6123.0) -
command を表示してから IO.popen の実行します。
...command を表示してから IO.popen の実行します。
@param command コマンド名を指定します。
@param mode オープンする IO ポートのモードを指定します。mode の詳細は Kernel.#open 参照して下さい。
@see IO.popen... -
Kernel
# xpopen(command , *mode) { . . . } -> object (6123.0) -
command を表示してから IO.popen の実行します。
...command を表示してから IO.popen の実行します。
@param command コマンド名を指定します。
@param mode オープンする IO ポートのモードを指定します。mode の詳細は Kernel.#open 参照して下さい。
@see IO.popen... -
Kernel
. # spawn(env , program , *args , options={}) -> Integer (31.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......列を指定します。
@param options オプションパラメータ Hash
@raise ArgumentError 第一引数が配列かつ要素数が 2 でない場合に発生します。
@raise Errno::EXXX コマンドが実行できなかった場合に発生します。
@see Kernel.#system,Kernel.#exec......din), 1(stdout), 2(stderr) 以外の
ファイルデスクリプタをすべて閉じます。
false がデフォルトです。
: :exception
Kernel.#system のみで指定できます。
これを true に設定すると、nil や false を返す代わりに例外が発生します。
fa......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 (31.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......列を指定します。
@param options オプションパラメータ Hash
@raise ArgumentError 第一引数が配列かつ要素数が 2 でない場合に発生します。
@raise Errno::EXXX コマンドが実行できなかった場合に発生します。
@see Kernel.#system,Kernel.#exec......din), 1(stdout), 2(stderr) 以外の
ファイルデスクリプタをすべて閉じます。
false がデフォルトです。
: :exception
Kernel.#system のみで指定できます。
これを true に設定すると、nil や false を返す代わりに例外が発生します。
fa......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 (13.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 (13.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={}) -> () (7.0) -
引数で指定されたコマンドを実行します。
...イルデスクリプタなど)引き継ぎます。
Hash を options として渡すことで、この挙動を変更できます。
詳しくは Kernel.#spawn を参照してください。
=== 引数の解釈
この形式で呼び出した場合、空白や shell のメタキャラクタも
そ......替えて以下を実行
$ 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={}) -> () (7.0) -
引数で指定されたコマンドを実行します。
...イルデスクリプタなど)引き継ぎます。
Hash を options として渡すことで、この挙動を変更できます。
詳しくは Kernel.#spawn を参照してください。
=== 引数の解釈
この形式で呼び出した場合、空白や shell のメタキャラクタも
そ......替えて以下を実行
$ 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 (7.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 (7.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)...