Crate getargv

Source
Expand description

Safe Rust wrapper for the getargv library.

This crate provides a safe wrapper for the getargv-sys crate which provides FFI bindings to libgetargv which provides a correct parser for the KERN_PROCARGS2 sysctl which is how you access the arguments of another process on macOS.

This is the preferred crate for using libgetargv in your Rust project.

§External Deps

You must have libgetargv installed for this crate to link to, it will not build/install it for you. If libgetargv.dylib is not located in one of clang’s default search paths, you must set theLIBGETARGV_LIB_DIR env var to tell rustc where to find it, and you will either need to set the DYLD_FALLBACK_LIBRARY_PATH env var at runtime to tell dyld where to load it from, or you will need to use install_name_tool on your binary to fixup the library load path.

§Reason this crate is macOS only

On BSDs and Linuxen you can just read /proc/$PID/cmdline which is both faster and easier than using this lib, Solaris has pargs, and I don’t use Windows so I can’t support it, but you might want to look at the wmic tool.

If you are writing a cross platform program, you can depend on this crate only on macOS by specifying the dependency as:

[target.'cfg(target_vendor = "apple")'.dependencies]
getargv = "~PKG_VERSION"

Modules§

argv
Fast way to obtain and print a representation of the arguments of a process.
argvargc
Provides an Iterator over the arguments of a process.

Structs§

Argv
Contains a printable representation of the arguments as parsed by get_argv_of_pid.
ArgvArgc
Contains an iterable representation of the arguments as parsed by get_argv_and_argc_of_pid.

Functions§

get_argv_and_argc_of_pid
Parses the arguments of a process, and on success returns an Iterator over them.
get_argv_of_pid
Parses the arguments of another process into a printable format.