Cmd: send a child's stdout or stderr to a file
Maintainer antworten meist innerhalb von 1 Tag
Ein zugehöriger Pull Request wurde bereits gemerged.
- #534 von @lukewilliamboswell — gemerged
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 48/100
Rechercherichtung
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.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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.
- Vorherrschende Sprache
- Rust
- Sterne
- 122
- Forks
- 47
- Ø Merge
- 11 Std. 6 Min.
- Gemergte PRs (30 T.)
- 21
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus roc-lang/basic-cli
-
Unix socket supportOffen
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 45/100
roc-lang/basic-cli#500 · 1 Kommentar · 1 Reaktion ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 25/100
roc-lang/basic-cli#482 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 45/100
Maintainer antworten meist innerhalb von 1 Tag
-
enhancement
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 45/100
roc-lang/basic-cli#455 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 32/100
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in roc-lang/basic-cli
Ähnliche Issues
-
llm translation
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
BerriAI/litellm#47884 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug(stubgen): `typing` / `_typeshed` imports are emitted above `from __future__ import annotations`Offenstubgen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
Maintainer antworten meist innerhalb von 2 Tagen
-
bug-hunt confirmed good first issue
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
Maintainer antworten meist innerhalb von 1 Tag
-
area: pcb area: rendering priority: high status: needs-triage type: bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 67/100
-
Update webpki-root-certsOffen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
rustls/rustls-platform-verifier#262 · 2 Kommentare · 2 Reaktionen ·