CX Framework
Cross-platform C utility framework
Loading...
Searching...
No Matches
Process Struct Reference

#include <processobj.h>

Public Member Functions

 atomic (bool) exited
 Set once the outcome is known and cached in the two fields below.
 

Data Fields

int64 pid
 OS process id.
 
int64 starttime
 
bool ischild
 cx forked this process, so cx is responsible for reaping it
 
int32 exitcode
 Valid once exited is set; PROC_ExitCodeUnknown if statusknown is false.
 
int32 termsignal
 Unix: signal that killed it, 0 if it exited normally.
 
bool statusknown
 
int64 watchid
 Exit watcher registration id, 0 if never registered.
 
string name
 Cached, best-effort.
 
string exepath
 Cached, best-effort.
 
Mutex lock
 Guards publication of the exit state.
 
sa_closure onexit
 Exit subscribers, fired once outside the lock.
 

Detailed Description

A process cx launched or attached to

This is a base class; the platform layer provides the derived class holding the native handle. Release it with procRelease() when finished.

Definition at line 37 of file processobj.h.

Member Function Documentation

◆ atomic()

Process::atomic ( bool  )

Set once the outcome is known and cached in the two fields below.

Read with acquire ordering; everything published before it is then safe to read without the lock, which is how the exit status outlives the reap.

Field Documentation

◆ ischild

bool Process::ischild

cx forked this process, so cx is responsible for reaping it

Only a child can be waited on, which is also why a process cx did not fork cannot report an exit code.

Definition at line 53 of file processobj.h.

◆ starttime

int64 Process::starttime

When the process started, used to detect a reused pid

Definition at line 48 of file processobj.h.

◆ statusknown

bool Process::statusknown

Set with exited when a real exit status was collected

Definition at line 61 of file processobj.h.

◆ watchid

int64 Process::watchid

Exit watcher registration id, 0 if never registered.

Ids are never reused, so a stale notification for a registration that was since cancelled cannot be mistaken for a new one at the same address.

Definition at line 66 of file processobj.h.


The documentation for this struct was generated from the following file: