getargv

package module
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 3, 2024 License: BSD-3-Clause Imports: 2 Imported by: 0

README

getargv

Go

This package allows you to query the arguments of other processes on macOS.

Installation

Install the package and add to the application's go.mod file by executing:

$ go get github.com/getargv/getargv.go@latest

If go.mod is not being used to manage dependencies, import the package with:

import "github.com/getargv/getargv.go"

Usage

Getargv.asString(some_process_id, 0, false) #=> "arg0\x00arg1\x00"
Getargv.asBytes(some_process_id, 0, false) #=> []byte("arg0\x00arg1\x00")
Getargv.asStrings(some_process_id) #=> ["arg0","arg1"]

Development

After checking out the repo, run go test to run the tests.

Go code goes in getargv.go. Test code in getargv_test.go.

To install this package onto your local machine, run go install. To release a new version, create a tag and push to GitHub which should get picked up by pkg.go.dev.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/getargv/getargv.go.

License

The package is available as open source under the terms of the BSD 3-clause License.

Documentation

Rendered for darwin/amd64

Overview

Package getargv fetches the arguments of other processes in multiple formats

The getargv package can only be used on macOS, because other operating systems have other means of accessing these arguments.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AsBytes

func AsBytes(pid pid_t, skip uint, nuls bool) ([]byte, error)

AsBytes gets the arguments of pid as a slice of bytes, with skip leading arguments skipped, and NUL bytes replaced with spaces if nuls is true it can return an error if:

  • the caller does not have permission to view the arguments of the target pid
  • the target pid does not exist
  • the kernel returns the targeted pid's args in an invalid format
  • the targeted pid's args are too long (somehow longer than ARG_MAX) and cannot be parsed safely.
  • AsBytes was asked to skip more args than targeted pid has.

func AsString

func AsString(pid pid_t, skip uint, nuls bool) (string, error)

AsString gets the arguments of pid as a string, with skip leading arguments skipped, and NUL bytes replaced with spaces if nuls is true it can return an error if:

  • the caller does not have permission to view the arguments of the target pid
  • the target pid does not exist
  • the kernel returns the targeted pid's args in an invalid format
  • the targeted pid's args are too long (somehow longer than ARG_MAX) and cannot be parsed safely.
  • AsString was asked to skip more args than targeted pid has.

func AsStrings

func AsStrings(pid pid_t) ([]string, error)

AsStrings gets the arguments of pid as a slice of strings, it can return an error if:

  • the caller does not have permission to view the arguments of the target pid
  • the target pid does not exist
  • the kernel returns the targeted pid's args in an invalid format
  • the targeted pid's args are too long (somehow longer than ARG_MAX) and cannot be parsed safely.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL