getargv has five flags, three of which are purely information about itself. You use the standard -0 flag to print arguments ␀ separated, the -s flag to strip leading arguments, the -v flag to print
getargv's version, and either of -h or -? to print a usage string. That's it, that's the whole interface.
getargv runs in approx 0.6 ㎳ on an M2 MacBook Air as measured by
hyperfine. It does this by utilizing a zero-copy single-scan algorithm to run in
O(n) time where n is the length of the arguments passed to the process you are inspecting, in Bytes.
getargv allocates at-most one relatively small block of memory, and stops reading the buffer once it finds the end of the process' arguments.
getargv also prints the arguments to stdout using pointers back to the original buffer, without copying.
getargv can handle the case where the process you are inspecting has an empty or missing argv.
getargv can handle the process you are inspecting having been called with empty arguments in all positions.
getargv can handle the case where the process you are inspecting has no arguments at all.
getargv knows that the PID_MAX differs based on the macOS version, and checks accordingly.
getargv handles being called with incorrect arguments, and prints helpful error messages.
sysctl does not differentiate between a PID not existing or your user not having permission to examine it,