Getargv 0.8.0
dotnet add package Getargv --version 0.8.0
NuGet\Install-Package Getargv -Version 0.8.0
<PackageReference Include="Getargv" Version="0.8.0" />
<PackageVersion Include="Getargv" Version="0.8.0" />
<PackageReference Include="Getargv" />
paket add Getargv --version 0.8.0
#r "nuget: Getargv, 0.8.0"
#:package Getargv@0.8.0
#addin nuget:?package=Getargv&version=0.8.0
#tool nuget:?package=Getargv&version=0.8.0
<h1><img src="logo.svg" width="200" alt="getargv"></h1>
libgetargv is a library that allows you to get the arguments that were passed to another running process on macOS. It is intended to provide roughly the same functionality as reading from /proc/<pid>/cmdline on Linux. On macOS this is done by parsing the output of the KERN_PROCARGS2 sysctl, which is <abbr title="always, in my observation">very often</abbr> implemented incorrectly, due to the overlooked possibility of leading empty arguments passed to the target process. This package is the C# bindings for the libgetargv library.
Permissions
libgetargv can only see processes running as the same user by default, so be sure your process runs as the desired user (setuid, launchd.plist, sudo) or can elevate privileges; n.b. elevating privileges safely is extremely complicated, and will be a target of privilege escalation attacks on macOS so be extremely careful if you go this route, better to defer to the user to elevate privileges for you as needed.
System Requirements
macOS is required as this is a macOS specific sysctl, even BSD does not implement it. Your system must support sysctl and KERN_PROCARGS2, which probably means macOS 10.3 or later, though I haven't tested versions older than 10.7. You'll also need a non-ancient clang (c99 is required) or you'll have to override the compiler flags with CC, EXTRA_CPPFLAGS, and EXTRA_CFLAGS.
Building getargv.cs
To make getargv.cs:
- Install
libgetargvto your system (see below). - Clone this repo and run
dotnet buildor - Add a
<PackageReference>entry to the<ItemGroup>property in your.csprojfile:<PackageReference Include="Getargv" Version="0.1.1" />
Installing libgetargv
To get access to libgetargv, sign up for an appropriate sponsorship tier.
Clone the libgetargv repo: git clone https://github.com/getargv/getargv.git.
Running make install_dylib, installs the library to the /usr/local/ prefix by default; you can change the install location with the PREFIX make variable: make PREFIX=/opt install_dylib.
I'm working on building binary artifacts to install without compilation, using pkg installers, however even once that's done, depending on your system, it may still be necessary to compile from source; eg. if you have built your own xnu kernel with a custom PID_MAX value.
Building libgetargv
I've built libgetargv on each version of macOS from 10.7 on using only the <abbr title="Command Line Tools">CLT</abbr> package, not the full Xcode install. If you need to override variables, do so inside the make command, eg: make EXTRA_CPPFLAGS=-DMACRO EXTRA_CFLAGS=-std=c17 dylib. Since c# did not exist when 10.6 was current, that should not be a concern for this project.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- No dependencies.
-
net8.0
- No dependencies.
-
net9.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.