Implement getrusage syscall for resource usage statistics #606
+159
−2
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.
Summary
Add support for the Linux
getrusage(2)syscall which returns resource usage statistics for the calling process, its children, or the calling thread.Syscall Signature
Parameters
who: Specifies whose resource usage to returnRUSAGE_SELF(0): Statistics for the calling processRUSAGE_CHILDREN(-1): Statistics for terminated and waited-for childrenRUSAGE_THREAD(1): Statistics for the calling threadChanges
litebox_common_linux/src/lib.rsRusagestruct,RusageWhoenum,Getrusagesyscall variantlitebox_shim_linux/src/lib.rsGetrusagelitebox_shim_linux/src/syscalls/process.rssys_getrusagelitebox_shim_linux/src/syscalls/tests.rsImplementation Notes
Returns a zeroed
Rusagestruct for all cases. This is valid because:Error Handling
EFAULTusagepoints outside accessible address spaceEINVALwhois invalid (handled during syscall parsing)Test Coverage
test_getrusage_self- Tests RUSAGE_SELF varianttest_getrusage_thread- Tests RUSAGE_THREAD varianttest_getrusage_children- Tests RUSAGE_CHILDREN variantTest plan
cargo fmtcleancargo clippyclean🤖 Generated with Claude Code