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
- func Folder(dir string) string
- func Keys(dir string) []string
- func Live(dir, key string) bool
- func NewKey() string
- func Orphaned(dir string) bool
- func PruneOrphans(dir string, keep func(Child) bool) error
- func Settled(dir string) (string, bool)
- type Child
- type Process
- type Self
- type Window
Constants ¶
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 ¶
Folder returns the folder of the records of the processes of the settings folder, which a watch of them watches.
func Keys ¶
Keys of the live processes of the settings folder, one whose record or lock file was deleted by hand included
func Live ¶
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 ¶
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 ¶
Keeps of the orphans only those keep says still run
func Settled ¶
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
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 ¶
Processes that ended without closing their record; each is returned to one caller once, then removed
type Self ¶
type Self struct {
// contains filtered or unexported fields
}
This process's record, which it holds the lock of until Close
func Join ¶
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 ¶
Removes the record and releases its lock, moving children still running to the orphans list; closing again does nothing
func (*Self) Keep ¶
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