running

package
v2.0.4 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2026 License: MIT Imports: 17 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package running keeps a record of each icebath process using a settings folder: what it is, its windows and their profiles, and the programs it started. A process holds its record's lock for its whole life, so a held lock means the process runs. A lock nobody holds means it ended only once its system says so too, or, for a process of another computer, once the lock stayed free for lockWait: a lock file deleted by hand, or one being made, is not held either

Index

Constants

View Source
const (
	AsWindow  = "window"
	AsServer  = "server"
	AsCommand = "command"
)

What a process is: a terminal running the app, icebath server, or a command run once

Variables

This section is empty.

Functions

func Folder

func Folder(dir string) string

Folder returns the folder of the records of the processes of the settings folder, which a watch of them watches.

func Keys

func Keys(dir string) []string

Keys of the live processes of the settings folder, one whose record or lock file was deleted by hand included

func Live

func Live(dir, key string) bool

Whether the process of the key still runs; a dead process's record moves to the ended ones

func NewKey

func NewKey() string

New key of a process: its pid, the moment it was made in nanoseconds, eight random hex digits, the start time of the process as its system reads it (zero when it tells none) and the place it runs in. No two processes alive at one moment share a pid, and a later process given the pid again starts at a later moment, so a key once found dead never names a live process. The pid, the start time and the place let another process of that place ask the system whether this one still runs

func Orphaned

func Orphaned(dir string) bool

Whether the settings folder keeps long-lived programs whose icebath ended, some of which may still run: one look at the size of the file of them, which holds no program while it holds an empty list or none

func PruneOrphans

func PruneOrphans(dir string, keep func(Child) bool) error

Keeps of the orphans only those keep says still run

func Settled

func Settled(dir string) (string, bool)

Stamp of the records of the settings folder, one look at their folder: every record is added, written again and removed whole in its place there, so the stamp changes as a process comes, changes what its record says or goes. A process that ends without removing its record changes nothing here, so whoever waits on that process tests its lock. And whether the folder was settled then (fsx.Settled): a look taken while it was not is taken again, as two records written within one tick of the folder's times can leave the stamp as it was

Types

type Child

type Child struct {
	PID     int       `json:"pid"`
	Started time.Time `json:"started"`
	// Start time of the program as the system reads it, which tells it from a later program given the same pid; zero when unknown
	Start int64 `json:"start_ticks,omitempty"`
	// Boot of the computer it started in, empty where the system names none
	Boot    string `json:"boot,omitempty"`
	Purpose string `json:"purpose"`
	Profile string `json:"profile"`
	// First words of its command line
	Argv string `json:"argv,omitempty"`
	// Key of the process that started it
	Spawner string `json:"spawner,omitempty"`
}

One long-lived program a process started

func Orphans

func Orphans(dir string) []Child

Long-lived programs whose icebath ended while they still ran, as last kept; some may have ended since

type Process

type Process struct {
	// Key NewKey made for it, the key of its presence record too
	Key     string    `json:"key"`
	PID     int       `json:"pid"`
	Started time.Time `json:"started"`
	// Boot of the computer it runs in, empty where the system names none
	Boot    string `json:"boot,omitempty"`
	Host    string `json:"host"`
	Purpose string `json:"purpose"`
	// Install of its program, the program and the version it runs
	Install string `json:"install"`
	Program string `json:"program"`
	Version string `json:"version,omitempty"`
	// Profile the process started on
	Start string `json:"start_profile,omitempty"`
	// Key of the icebath process whose program started this one, empty for none
	Spawner  string   `json:"spawner,omitempty"`
	Windows  []Window `json:"windows"`
	Children []Child  `json:"children"`
	// Number of the last act on a profile in the settings folder's journal this process stopped its work for
	Acked int64 `json:"acked,omitempty"`
	// When a process found it ended without closing its record; zero while it runs
	Found time.Time `json:"found,omitzero"`
}

One icebath process as its record says

func Ended

func Ended(dir string) []Process

Processes that ended without closing their record; each is returned to one caller once, then removed

func Find

func Find(dir, key string) (Process, bool)

Record of the live process of the key

func List

func List(dir string) []Process

Live processes of the settings folder, oldest first; records of dead ones move to the ended ones

func (Process) Profiles

func (p Process) Profiles() []string

Profiles the windows of the process are on, each once

type Self

type Self struct {
	// contains filtered or unexported fields
}

This process's record, which it holds the lock of until Close

func Join

func Join(dir string, p Process) (*Self, error)

Writes this process's record and holds its lock until Close, filling in an empty key, pid, start, boot and host. A process whose record can't be written must not own sessions

func (*Self) Close

func (s *Self) Close() error

Removes the record and releases its lock, moving children still running to the orphans list; closing again does nothing

func (*Self) Dir

func (s *Self) Dir() string

Settings folder of the record

func (*Self) Keep

func (s *Self) Keep(what string, has bool)

Says whether this process has the thing named, which another process would take from it once it read as ended: a session it owns, an act on a profile under way. While it has any, or a window or a program it started, it looks at its lock file every lockMend

func (*Self) Key

func (s *Self) Key() string

Key of this process's record

func (*Self) Mend

func (s *Self) Mend()

Puts back the lock file or the record when one was deleted while the process runs, so other processes still find it live

func (*Self) Process

func (s *Self) Process() Process

This process as its record says now

func (*Self) Update

func (s *Self) Update(change func(*Process)) error

Changes this process's record and writes it again. The key, pid and start stay as they are whatever change does

type Window

type Window struct {
	ID      string `json:"id"`
	Profile string `json:"profile"`
}

One window a process hosts and the profile it is on now

Jump to

Keyboard shortcuts

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