getargv(1) General Commands Manual getargv(1)

getargvprint a process' arguments

getargv [-0] [-s skip] pid

getargv [-? | -h] [-v]

The getargv utility prints all or some of the arguments in the argv array of a process pid.

The options are as follows:

Print the list of arguments delimited by the ASCII NUL character (character code 0x00). The default is to delimit the arguments by the ASCII space character (character code 0x20).
Skip the specified number of arguments starting from the beginning of the list. -s 1 would skip the process name (argv[0]), -s 2 skips the process name and the first argument.
Prints the version number.
These two equivalent options select a usage (help) output message. (Escape the "?" character as your shell requires.)

getargv is only able to see the arguments of processes owned by the user that ran it, unless run by root.

Print the NUL delimited arguments of the parent process of your shell; without the process name, just the args. Useful for piping to xargs -0 getopt

getargv assumes that you have not compiled your own xnu kernel with a custom PID_MAX, if you have you will need to compile getargv with your custom PID_MAX set thus:


Also, it is currently a hard requirement that PID_MAX < ARG_MAX.

The getargv command was adapted from nonowarn's getargv gist
Which was itself extracted from the ps(1) source code.

ps(1), argv(3), sysctl(8)

Camden Narzt ⟨⟩

See LICENSE file

January 5, 2023 Darwin