Cmd: send a child's stdout or stderr to a file
メンテナーはふだん 1 日以内に返信
関連するプルリクエストがすでにマージされています。
- #534 @lukewilliamboswell による — マージ済み
評価
調査の方向性
Start by reading the existing Cmd stdout and stderr mode definitions and spawn implementation, then check their tests to see how child output is currently handled. The issue sketches file output modes with truncate or append behavior and merging stderr with stdout; compare those options with the existing API style. Done means a child can send stdout or stderr to a file as described, with tests covering the selected modes.
索引モデルが issue の本文から書いたものです。
説明
A child's standard output can be inherited, discarded, captured, tee'd or piped, but not sent to a file. A long-running child whose output should end up on disk then needs a shell for the redirect:
child = Cmd.new("bash").args(["-c", "ssh … 'journalctl -k -f' > server.log 2>&1"]).spawn!()?
Our case: a race tool follows a remote server's kernel log and memory over one ssh session for hours, into a file (the "black box" read after a crash). The app is single-threaded and busy driving load the whole time, so it cannot read a Pipe and write the file itself. With Go we set cmd.Stdout to an *os.File.
A sketch, keeping Cmd's style:
StdoutMode : [Inherit, InheritStderr, Null, Capture, Tee, Pipe, File(Path, [Truncate, Append])]
StderrMode : [..., File(Path, [Truncate, Append]), MergeWithStdout]
child = Cmd.new("ssh").args(args).stdout(File("server.log", Truncate)).stderr(MergeWithStdout).spawn!()?
Opening the file in the host (with O_APPEND for Append) before the spawn would also make the redirect atomic in the way a shell's is. Could also take File.WriterOptions for its permissions.
Seen on 0.26.0-rc3.
- 主要言語
- Rust
- スター
- 122
- フォーク
- 47
- 平均マージ
- 11時間 6分
- マージ済み PR(30日)
- 21
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
roc-lang/basic-cli のほかの issue
-
Unix socket supportオープン
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
roc-lang/basic-cli#500 · コメント 1 件 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
roc-lang/basic-cli#482 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 5/5 1週間以上 初心者へのやさしさ 45/100
roc-lang/basic-cli#455 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 32/100
メンテナーはふだん 1 日以内に返信
roc-lang/basic-cli の issue をすべて見る
似ている issue
-
good first issue help wanted r-feature
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
servo/rust-smallvec#792 ·
メンテナーはふだん 1 日以内に返信
-
A-Unicode C-bug P-low
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
rust-lang/rustfmt#7210 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1〜3時間 初心者へのやさしさ 86/100
メンテナーはふだん 1 日以内に返信
-
area:sim good first issue kind:feature
難易度 2/5 1〜3時間 初心者へのやさしさ 87/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
bitcoindevkit/bdk#2432 ·
メンテナーはふだん 3 日以内に返信