fix: don't write empty stdout and stderr
This commit is contained in:
parent
9aa142ffa6
commit
1689848851
6 changed files with 74 additions and 48 deletions
|
@ -321,10 +321,12 @@ pub fn run() -> anyhow::Result<()> {
|
||||||
|
|
||||||
stdout.read_to_end(&mut buf)?;
|
stdout.read_to_end(&mut buf)?;
|
||||||
|
|
||||||
for line in buf.split(|c| c == &b'\n') {
|
if !buf.is_empty() {
|
||||||
game_output.write_all(b" [stdout] ")?;
|
for line in buf.split(|c| c == &b'\n') {
|
||||||
game_output.write_all(line)?;
|
game_output.write_all(b" [stdout] ")?;
|
||||||
game_output.write_all(b"\n")?;
|
game_output.write_all(line)?;
|
||||||
|
game_output.write_all(b"\n")?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -334,10 +336,12 @@ pub fn run() -> anyhow::Result<()> {
|
||||||
|
|
||||||
stderr.read_to_end(&mut buf)?;
|
stderr.read_to_end(&mut buf)?;
|
||||||
|
|
||||||
for line in buf.split(|c| c == &b'\n') {
|
if !buf.is_empty() {
|
||||||
game_output.write_all(b"[!] [stderr] ")?;
|
for line in buf.split(|c| c == &b'\n') {
|
||||||
game_output.write_all(line)?;
|
game_output.write_all(b"[!] [stderr] ")?;
|
||||||
game_output.write_all(b"\n")?;
|
game_output.write_all(line)?;
|
||||||
|
game_output.write_all(b"\n")?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -347,6 +351,8 @@ pub fn run() -> anyhow::Result<()> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
game_output.flush()?;
|
||||||
|
|
||||||
// Workaround for fast process closing (is it still a thing?)
|
// Workaround for fast process closing (is it still a thing?)
|
||||||
loop {
|
loop {
|
||||||
std::thread::sleep(std::time::Duration::from_secs(3));
|
std::thread::sleep(std::time::Duration::from_secs(3));
|
||||||
|
|
|
@ -274,10 +274,12 @@ pub fn run() -> anyhow::Result<()> {
|
||||||
|
|
||||||
stdout.read_to_end(&mut buf)?;
|
stdout.read_to_end(&mut buf)?;
|
||||||
|
|
||||||
for line in buf.split(|c| c == &b'\n') {
|
if !buf.is_empty() {
|
||||||
game_output.write_all(b" [stdout] ")?;
|
for line in buf.split(|c| c == &b'\n') {
|
||||||
game_output.write_all(line)?;
|
game_output.write_all(b" [stdout] ")?;
|
||||||
game_output.write_all(b"\n")?;
|
game_output.write_all(line)?;
|
||||||
|
game_output.write_all(b"\n")?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -287,10 +289,12 @@ pub fn run() -> anyhow::Result<()> {
|
||||||
|
|
||||||
stderr.read_to_end(&mut buf)?;
|
stderr.read_to_end(&mut buf)?;
|
||||||
|
|
||||||
for line in buf.split(|c| c == &b'\n') {
|
if !buf.is_empty() {
|
||||||
game_output.write_all(b"[!] [stderr] ")?;
|
for line in buf.split(|c| c == &b'\n') {
|
||||||
game_output.write_all(line)?;
|
game_output.write_all(b"[!] [stderr] ")?;
|
||||||
game_output.write_all(b"\n")?;
|
game_output.write_all(line)?;
|
||||||
|
game_output.write_all(b"\n")?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -264,10 +264,12 @@ pub fn run() -> anyhow::Result<()> {
|
||||||
|
|
||||||
stdout.read_to_end(&mut buf)?;
|
stdout.read_to_end(&mut buf)?;
|
||||||
|
|
||||||
for line in buf.split(|c| c == &b'\n') {
|
if !buf.is_empty() {
|
||||||
game_output.write_all(b" [stdout] ")?;
|
for line in buf.split(|c| c == &b'\n') {
|
||||||
game_output.write_all(line)?;
|
game_output.write_all(b" [stdout] ")?;
|
||||||
game_output.write_all(b"\n")?;
|
game_output.write_all(line)?;
|
||||||
|
game_output.write_all(b"\n")?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -277,10 +279,12 @@ pub fn run() -> anyhow::Result<()> {
|
||||||
|
|
||||||
stderr.read_to_end(&mut buf)?;
|
stderr.read_to_end(&mut buf)?;
|
||||||
|
|
||||||
for line in buf.split(|c| c == &b'\n') {
|
if !buf.is_empty() {
|
||||||
game_output.write_all(b"[!] [stderr] ")?;
|
for line in buf.split(|c| c == &b'\n') {
|
||||||
game_output.write_all(line)?;
|
game_output.write_all(b"[!] [stderr] ")?;
|
||||||
game_output.write_all(b"\n")?;
|
game_output.write_all(line)?;
|
||||||
|
game_output.write_all(b"\n")?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -275,10 +275,12 @@ pub fn run() -> anyhow::Result<()> {
|
||||||
|
|
||||||
stdout.read_to_end(&mut buf)?;
|
stdout.read_to_end(&mut buf)?;
|
||||||
|
|
||||||
for line in buf.split(|c| c == &b'\n') {
|
if !buf.is_empty() {
|
||||||
game_output.write_all(b" [stdout] ")?;
|
for line in buf.split(|c| c == &b'\n') {
|
||||||
game_output.write_all(line)?;
|
game_output.write_all(b" [stdout] ")?;
|
||||||
game_output.write_all(b"\n")?;
|
game_output.write_all(line)?;
|
||||||
|
game_output.write_all(b"\n")?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -288,10 +290,12 @@ pub fn run() -> anyhow::Result<()> {
|
||||||
|
|
||||||
stderr.read_to_end(&mut buf)?;
|
stderr.read_to_end(&mut buf)?;
|
||||||
|
|
||||||
for line in buf.split(|c| c == &b'\n') {
|
if !buf.is_empty() {
|
||||||
game_output.write_all(b"[!] [stderr] ")?;
|
for line in buf.split(|c| c == &b'\n') {
|
||||||
game_output.write_all(line)?;
|
game_output.write_all(b"[!] [stderr] ")?;
|
||||||
game_output.write_all(b"\n")?;
|
game_output.write_all(line)?;
|
||||||
|
game_output.write_all(b"\n")?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -255,10 +255,12 @@ pub fn run() -> anyhow::Result<()> {
|
||||||
|
|
||||||
stdout.read_to_end(&mut buf)?;
|
stdout.read_to_end(&mut buf)?;
|
||||||
|
|
||||||
for line in buf.split(|c| c == &b'\n') {
|
if !buf.is_empty() {
|
||||||
game_output.write_all(b" [stdout] ")?;
|
for line in buf.split(|c| c == &b'\n') {
|
||||||
game_output.write_all(line)?;
|
game_output.write_all(b" [stdout] ")?;
|
||||||
game_output.write_all(b"\n")?;
|
game_output.write_all(line)?;
|
||||||
|
game_output.write_all(b"\n")?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -268,10 +270,12 @@ pub fn run() -> anyhow::Result<()> {
|
||||||
|
|
||||||
stderr.read_to_end(&mut buf)?;
|
stderr.read_to_end(&mut buf)?;
|
||||||
|
|
||||||
for line in buf.split(|c| c == &b'\n') {
|
if !buf.is_empty() {
|
||||||
game_output.write_all(b"[!] [stderr] ")?;
|
for line in buf.split(|c| c == &b'\n') {
|
||||||
game_output.write_all(line)?;
|
game_output.write_all(b"[!] [stderr] ")?;
|
||||||
game_output.write_all(b"\n")?;
|
game_output.write_all(line)?;
|
||||||
|
game_output.write_all(b"\n")?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -273,10 +273,12 @@ pub fn run() -> anyhow::Result<()> {
|
||||||
|
|
||||||
stdout.read_to_end(&mut buf)?;
|
stdout.read_to_end(&mut buf)?;
|
||||||
|
|
||||||
for line in buf.split(|c| c == &b'\n') {
|
if !buf.is_empty() {
|
||||||
game_output.write_all(b" [stdout] ")?;
|
for line in buf.split(|c| c == &b'\n') {
|
||||||
game_output.write_all(line)?;
|
game_output.write_all(b" [stdout] ")?;
|
||||||
game_output.write_all(b"\n")?;
|
game_output.write_all(line)?;
|
||||||
|
game_output.write_all(b"\n")?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -286,10 +288,12 @@ pub fn run() -> anyhow::Result<()> {
|
||||||
|
|
||||||
stderr.read_to_end(&mut buf)?;
|
stderr.read_to_end(&mut buf)?;
|
||||||
|
|
||||||
for line in buf.split(|c| c == &b'\n') {
|
if !buf.is_empty() {
|
||||||
game_output.write_all(b"[!] [stderr] ")?;
|
for line in buf.split(|c| c == &b'\n') {
|
||||||
game_output.write_all(line)?;
|
game_output.write_all(b"[!] [stderr] ")?;
|
||||||
game_output.write_all(b"\n")?;
|
game_output.write_all(line)?;
|
||||||
|
game_output.write_all(b"\n")?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue