package psnotify

import "github.com/cloudfoundry/gosigar/psnotify"

Go interface to BSD kqueue process events.

Index

Constants

const (
	// Flags (from <sys/event.h>)
	PROC_EVENT_FORK = syscall.NOTE_FORK // fork() events
	PROC_EVENT_EXEC = syscall.NOTE_EXEC // exec() events
	PROC_EVENT_EXIT = syscall.NOTE_EXIT // exit() events

	// Watch for all process events
	PROC_EVENT_ALL = PROC_EVENT_FORK | PROC_EVENT_EXEC | PROC_EVENT_EXIT
)

Types

type ProcEventExec

type ProcEventExec struct {
	Pid int // Pid of the process that called exec()
}

type ProcEventExit

type ProcEventExit struct {
	Pid int // Pid of the process that called exit()
}

type ProcEventFork

type ProcEventFork struct {
	ParentPid int // Pid of the process that called fork()
	ChildPid  int // Child process pid created by fork()
}

type Watcher

type Watcher struct {
	Error chan error          // Errors are sent on this channel
	Fork  chan *ProcEventFork // Fork events are sent on this channel
	Exec  chan *ProcEventExec // Exec events are sent on this channel
	Exit  chan *ProcEventExit // Exit events are sent on this channel
	// contains filtered or unexported fields
}

func NewWatcher

func NewWatcher() (*Watcher, error)

Initialize event listener and channels

func (*Watcher) Close

func (w *Watcher) Close() error

Closes the OS specific event listener, removes all watches and closes all event channels.

func (*Watcher) RemoveWatch

func (w *Watcher) RemoveWatch(pid int) error

Remove pid from the watched process set.

func (*Watcher) Watch

func (w *Watcher) Watch(pid int, flags uint32) error

Add pid to the watched process set. The flags param is a bitmask of process events to capture, must be one or more of: PROC_EVENT_FORK, PROC_EVENT_EXEC, PROC_EVENT_EXIT

Source Files

psnotify.go psnotify_bsd.go

Version
v1.3.45
Published
Feb 3, 2024
Platform
darwin/amd64
Imports
4 packages
Last checked
19 minutes ago

Tools for package owners.