Skip to content

Conversation

@dweiller
Copy link

@dweiller dweiller commented Jun 20, 2023

Closes #9. Here is the output for a command failing.

I  ~/S/poop (child-stderr +) [1] > zig-out/bin/poop ls 'ls a' ls  -d 50
Benchmark 1 (24 runs): ls
  measurement      mean ± σ               minmax                   outliers         delta
  wall_time        1.432ms ± 484.231us    773.111us … 1.972ms           0 ( 0%)        0%
  peak_rss         2M ± 70K               2M … 2M                       0 ( 0%)        0%
  cpu_cycles       387633 ± 64478         354835 … 608024               3 (13%)        0%
  instructions     398961 ± 75            398903 … 399132               0 ( 0%)        0%
  cache_references 28741 ± 509            27592 … 30467                 2 ( 8%)        0%
  cache_misses     9038 ± 255             8693 … 9953                   1 ( 4%)        0%
  branch_misses    4892 ± 124             4712 … 5187                   0 ( 0%)        0%

error: Benchmark 2 command 'ls a' failed with exit code 2:
─────────────────── stderr ───────────────────
ls: cannot access 'a': No such file or directory
──────────────────────────────────────────────

Any benchmarks after the failed one are skipped.

I don't think it makes that much sense for poop to capture arbitrarily large amounts of stderr, so I think it makes sense to just truncate after a certain amount is captured. Due to the way std.io.Poller reads, it only really makes sense to use a power of two sized buffer - I chose 4096 for no particular reason. The waystd.io.Poller reads means that even if there is more than 4096 bytes of stderr, any where between 4096-512+1=3585 and 4096 bytes might be read as the poller always tries to read at least 512 bytes.

If the stderr is truncated the stderr will look like this:

────────────── stderr truncated ──────────────
ls: cannot access 'a': N
──────────────────────────────────────────────

But with presumably much more output

Copy link
Owner

@andrewrk andrewrk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!

@dweiller dweiller requested a review from andrewrk June 22, 2023 02:10
@andrewrk andrewrk merged commit 3750fed into andrewrk:main Jun 22, 2023
@andrewrk
Copy link
Owner

andrewrk commented Jun 22, 2023

edit: never mind me, I forgot to pull!

@dweiller dweiller deleted the child-stderr branch June 22, 2023 04:17
@andrewrk
Copy link
Owner

Reverted in 14e2f30. Your code has a deadlock in it, try testing with a program that outputs a lot of stderr.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

when a command fails, show the stderr by default

2 participants