381件ヒット
[1-100件を表示]
(0.037秒)
種類
- 特異メソッド (204)
- モジュール関数 (93)
- インスタンスメソッド (60)
- 文書 (12)
- 変数 (12)
ライブラリ
キーワード
-
$ DEFAULT _ OUTPUT (12) - chmod (12)
- header (12)
-
pipeline
_ rw (12) - popen (168)
- popen3 (12)
- readpartial (12)
-
ruby 1
. 6 feature (12) - spawn (48)
- stdout= (12)
- tcp (24)
- timeout (21)
検索結果
先頭5件
-
Gem
:: Package :: TarOutput # close (21117.0) -
自身に関連付けられた IO を close します。
...自身に関連付けられた IO を close します。... -
CGI
# out(options = "text / html") { . . . . } (18125.0) -
HTTP ヘッダと、ブロックで与えられた文字列を標準出力に出力します。
...ew
cgi.out{ "string" }
# Content-Type: text/html
# Content-Length: 6
#
# string
cgi.out("text/plain"){ "string" }
# Content-Type: text/plain
# Content-Length: 6
#
# string
cgi.out({"nph"......e,
"status" => "OK", # == "200 OK"
"server" => ENV['SERVER_SOFTWARE'],
"connection" => "close",
"type" => "text/html",
"charset" => "iso-2022-jp",
# Content-Type: text/html; char... -
Timeout
. # timeout(sec , exception _ class = nil) {|i| . . . } -> object (9106.0) -
ブロックを sec 秒の期限付きで実行します。 ブロックの実行時間が制限を過ぎたときは例外 Timeout::Error が発生します。
...秒の期限付きで実行します。
ブロックの実行時間が制限を過ぎたときは例外
Timeout::Error が発生します。
exception_class を指定した場合には Timeout::Error の代わりに
その例外が発生します。
ブロックパラメータ i は sec がはい......ト
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 = [ 0, 0]
begin
Timeout.timeout(t){
calc_pi(min)
}
rescue Timeout::Error
puts "timeout"
end
printf "%d:......m.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 (9106.0) -
ブロックを sec 秒の期限付きで実行します。 ブロックの実行時間が制限を過ぎたときは例外 Timeout::Error が発生します。
...秒の期限付きで実行します。
ブロックの実行時間が制限を過ぎたときは例外
Timeout::Error が発生します。
exception_class を指定した場合には Timeout::Error の代わりに
その例外が発生します。
ブロックパラメータ i は sec がはい......ト
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 = [ 0, 0]
begin
Timeout.timeout(t){
calc_pi(min)
}
rescue Timeout::Error
puts "timeout"
end
printf "%d:......m.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")... -
Kernel
$ $ DEFAULT _ OUTPUT -> IO (6118.0) -
$> の別名
...$> の別名
require "English"
dout = $DEFAULT_OUTPUT.dup
$DEFAULT_OUTPUT.reopen("out.txt", "w")
print "foo"
$DEFAULT_OUTPUT.close
$DEFAULT_OUTPUT = dout
p "bar" # => bar
p File.read("out.txt") #=> foo... -
Tracer
. stdout=(fp) (6106.0) -
トレース出力先を変更します。
...トレース出力先を変更します。
@param fp 新しいトレース出力先を指定します。
require 'tracer'
fp = File.open('temptrace.txt', "w")
Tracer.stdout = fp
Tracer.on {
puts "Hello"
}
fp.close... -
Kernel
. # spawn(env , program , *args , options={}) -> Integer (210.0) -
引数を外部コマンドとして実行しますが、生成した 子プロセスの終了を待ち合わせません。生成した子プロセスのプロセスIDを返します。
...タや
ファイル名を指定することでリダイレクトを実現できます。
: :close_others
これを true に設定すると
リダイレクトされていない、0(stdin), 1(stdout), 2(stderr) 以外の
ファイルデスクリプタをすべて閉じます。
true がデ......指定できます。
* :close キーで指定したファイルデスクリプタを子プロセス側で閉じます
ファイルデスクリプタを表すためには、以下が利用できます。
* :in 標準入力, ファイルデスクリプタ0
* :out 標準出力, ファイルデ......{
# 以下の例はすべて stderr を stdout にリダイレクトします
pid = spawn(command, :err=>:out)
pid = spawn(command, 2=>1)
pid = spawn(command, STDERR=>:out)
pid = spawn(command, STDERR=>STDOUT)
//}
この例では子プロセス側の stdout には触れていないので、
親プ......タや
ファイル名を指定することでリダイレクトを実現できます。
: :close_others
これを true に設定すると
リダイレクトされていない、0(stdin), 1(stdout), 2(stderr) 以外の
ファイルデスクリプタをすべて閉じます。
false がデ... -
Kernel
. # spawn(program , *args) -> Integer (210.0) -
引数を外部コマンドとして実行しますが、生成した 子プロセスの終了を待ち合わせません。生成した子プロセスのプロセスIDを返します。
...タや
ファイル名を指定することでリダイレクトを実現できます。
: :close_others
これを true に設定すると
リダイレクトされていない、0(stdin), 1(stdout), 2(stderr) 以外の
ファイルデスクリプタをすべて閉じます。
true がデ......指定できます。
* :close キーで指定したファイルデスクリプタを子プロセス側で閉じます
ファイルデスクリプタを表すためには、以下が利用できます。
* :in 標準入力, ファイルデスクリプタ0
* :out 標準出力, ファイルデ......{
# 以下の例はすべて stderr を stdout にリダイレクトします
pid = spawn(command, :err=>:out)
pid = spawn(command, 2=>1)
pid = spawn(command, STDERR=>:out)
pid = spawn(command, STDERR=>STDOUT)
//}
この例では子プロセス側の stdout には触れていないので、
親プ......タや
ファイル名を指定することでリダイレクトを実現できます。
: :close_others
これを true に設定すると
リダイレクトされていない、0(stdin), 1(stdout), 2(stderr) 以外の
ファイルデスクリプタをすべて閉じます。
false がデ... -
Open3
. # popen3(*cmd) {|stdin , stdout , stderr , wait _ thr| . . . } -> () (136.0) -
外部プログラム cmd を実行し、そのプロセスの標準入力、標準出力、標準エラー 出力に接続されたパイプと実行したプロセスを待つためのスレッドを 4 要素の 配列で返します。
...されたパイプと実行したプロセスを待つためのスレッドを 4 要素の
配列で返します。
require 'open3'
stdin, stdout, stderr, wait_thr = *Open3.popen3("/usr/bin/nroff -man")
@param cmd 実行するコマンドを指定します。
@return ブロックを指定し......プ
を close します。この場合はブロックの最後の式の結果を返します。
require 'open3'
Open3.popen3("read stdin; echo stdout; echo stderr >&2") {|stdin, stdout, stderr, wait_thr|
stdin.puts "stdin"
stdin.close # または close_write
p stdout.read
p......stderr.read
}
#=> "stdout\n"
"stderr\n"
stdin への入力が終わったらできる限り早く close か close_write
で閉じるべきです。
[UNIX系OS固有の注意] Open3 で作成した子プロセスは
wait(2) しなくてもゾンビになりません。
引数 cmd は...