JFLib

plat/pid.rs#

Source: lib/plat/pid.rs

Whether a process runs (process_alive) and this process's id (process_id), on every target:
Windows OpenProcess and a wait of 0 ms, Linux the kill system call with signal 0, Apple and
Android libc's kill; the browser has no processes.
  • fn process_id() -> u32 This process's id, as std::process::id() gives it (for apps without std); 0 in the browser.

  • fn process_alive(pid: u32) -> bool Whether a process with this id runs now: the owner of a lock file, a helper started earlier. A process of another user that this one may not open or signal counts too. Ids are reused: once a process ended, another one may get its id, so a lock file should hold more than the id where that matters (the program, its start time). A child of this process that ended still counts on Linux, Apple and Android until it is reaped (process::Child::try_wait keeps it, dropping the Child reaps it). Inside a Flatpak sandbox only the sandbox's own processes are seen (its PID namespace). 0 is never a process; the browser has none (false).

Source: docs/API.md in the JFLib repository.