Improve client and daemon CLI affordances#134
Merged
Merged
Conversation
Failed syscalls printed only the raw value ("-2 (error)"), leaving the
user to decode errno numbers by hand for the single most common tracing
task. Decode -errno returns through a libc-constant table:
openat(...) = -2 (ENOENT: No such file or directory)
All error formatting goes through the new format_error_return(); the
test suite's expectations are updated and integration tests gain an
@errno@ marker for errno-varying assertions.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves Pinchy’s client/daemon CLI usability and makes trace output/return formatting more strace-like across the codebase.
Changes:
- Decode raw
-errnosyscall returns into-N (ENAME: description)via centralizedformat_error_return()/errno_info()and update tests accordingly. - Improve CLI ergonomics: syscall listing, “did you mean” suggestions, accept
-e trace=...syntax, print usage on empty invocation, and send trace output tostderrby default (with-o/--outputfor files). - Make the daemon CLI behave like a proper CLI (
--help/--version), add a stable readiness marker, and adjust UML runner + integration assertions for the new output streams/markers.
Reviewed changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
uml-kernel/uml-test-runner.sh |
Wait for explicit daemon readiness marker; adjust latency probe to read trace output from stderr. |
README.md |
Update run instructions (separate client/daemon), add daemon installation guidance, and document new CLI flags/env knobs. |
pinchy/tests/integration.rs |
Move trace assertions from stdout to stderr; update expected errno formatting; add @ERRNO@ marker. |
pinchy/src/tests/time.rs |
Update expected formatted errno strings. |
pinchy/src/tests/system.rs |
Update expected formatted errno strings. |
pinchy/src/tests/sync.rs |
Update expected formatted errno strings. |
pinchy/src/tests/signal.rs |
Update expected formatted errno strings. |
pinchy/src/tests/security.rs |
Update expected formatted errno strings. |
pinchy/src/tests/scheduling.rs |
Update expected formatted errno strings. |
pinchy/src/tests/return_values.rs |
Validate new errno decoding behavior in format_return_value(). |
pinchy/src/tests/process.rs |
Update expected formatted errno strings. |
pinchy/src/tests/network.rs |
Update expected formatted errno strings. |
pinchy/src/tests/memory.rs |
Update expected formatted errno strings. |
pinchy/src/tests/ipc.rs |
Update expected formatted errno strings. |
pinchy/src/tests/filesystem.rs |
Update expected formatted errno strings. |
pinchy/src/server.rs |
Add clap parsing for daemon, SIGTERM handling, quieter logging, and a readiness marker. |
pinchy/src/format_helpers.rs |
Centralize errno decoding (errno_info, format_error_return) and use it throughout format_return_value. |
pinchy/src/client.rs |
Add syscall listing/suggestions, -o output support, default trace output to stderr, and updated flushing behavior. |
pinchy/Cargo.toml |
Add crate description and set default-run. |
pinchy-common/src/syscalls/mod.rs |
Export SYSCALL_ALIASES list from the syscall declaration macro. |
pinchy-client/src/lib.rs |
Improve exec failure exit codes and D-Bus error messaging/exit codes. |
.github/copilot-instructions.md |
Document new @ERRNO@ integration-test marker. |
Comment on lines
+56
to
+68
| // Only reached when exec failed. Use the shell convention: 126 for | ||
| // permission problems, 127 for command not found. | ||
| let err = std::io::Error::last_os_error(); | ||
| eprintln!( | ||
| "pinchy: cannot execute '{}': {err}", | ||
| command[0].to_string_lossy() | ||
| ); | ||
|
|
||
| let code = match err.raw_os_error() { | ||
| Some(libc::EACCES) | Some(libc::EPERM) => 126, | ||
| _ => 127, | ||
| }; | ||
| std::process::exit(code); |
Owner
Author
There was a problem hiding this comment.
Fixed and squashed into the affordances commit.
Owner
Author
There was a problem hiding this comment.
Fixed and squashed into the affordances commit.
Comment on lines
+98
to
+104
| // Tolerate a closed pipe (e.g. `pinchy --list-syscalls | head`). | ||
| let mut out = std::io::stdout().lock(); | ||
| for name in names { | ||
| if writeln!(out, "{name}").is_err() { | ||
| return; | ||
| } | ||
| } |
Owner
Author
There was a problem hiding this comment.
Fixed and squashed into the affordances commit.
Owner
Author
There was a problem hiding this comment.
Fixed and squashed into the affordances commit.
Client: - --list-syscalls prints the supported names; unknown -e names now get a did-you-mean suggestion (canonical names and aliases) and a pointer to the list - Accept strace's -e trace=name,... qualifier syntax - Distinguish "no such PID" (exit 9) from permission denied; suggest how to start the daemon when the service is not running (also for failed bus activation) - Failed exec of the traced command now prints why and exits with the shell convention (126/127) instead of silently exiting 255 - Give --format a help string and the crate a description so --help has an about line Daemon: - Parse arguments (--help/--version now work instead of being ignored) - Handle SIGTERM like SIGINT so systemctl stop closes the bus cleanly - Hint that root/CAP_BPF is needed when eBPF loading fails - Demote periodic "Currently serving" and startup chatter to debug logging; the journal no longer gets a line every 5 seconds README: document daemon installation (D-Bus policy/activation files, systemd unit), fix the cargo run line (needs --bin pinchyd), document --list-syscalls, --format and the tuning env vars. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Trace lines used to share stdout with the traced program's own output, making them impossible to separate. Follow strace's convention: stderr by default, or a file via -o/--output. Flush latency heuristics now look at the actual sink (stderr TTY, or threshold-only for files), and the no-arguments usage message goes to stderr as well. The daemon now prints a deliberate "Pinchy daemon ready" readiness marker, which the UML test runner waits for (it previously grepped for the "Waiting for Ctrl-C..." line that is now debug logging); the runner's latency probe and the test assertions read the trace from stderr. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Third PR from the review pass (after #132 and #133), focused on usability of the two CLIs.
Error returns are decoded strace-style:
= -2 (ENOENT: No such file or directory), via a full errno table built onlibcconstants;format_error_return()replaces the scattered open-coded error formatting.Client usability batch:
--list-syscallslists the supported names (SIGPIPE-safe for piping intohead).-e trace=name,...qualifier syntax is accepted.sudo systemctl start pinchy, a dead PID exits 9 with a clear message.pinchydpreviously had zero argument parsing (--helpstarted the daemon); it now uses clap, handles SIGTERM like SIGINT, demotes periodic status chatter to debug logging, and prints a deliberatePinchy daemon readyreadiness marker — which the UML test runner now waits for instead of grepping incidental log text.default-run = "pinchy".cargo runinvocation, new flags documented.Trace output goes to stderr by default (like strace), keeping the traced program's stdout clean, with
-o/--output FILEto write to a file instead; flushing is tuned so a TTY gets per-event output while files/pipes batch. Integration assertions moved from stdout to stderr accordingly.🤖 Generated with Claude Code