Expand description
This process: its id, the user it runs as, whether it is elevated, and the process guard every long-running service starts with.
sys-lib does not list or inspect other processes.
use sys_lib as sys;
println!("pid {} as {}", sys::process::id(), sys::process::user()?.name);
if sys::process::is_elevated()? {
println!("running as root or an elevated Administrator");
}Structs§
- Guard
guard - The running guard. Dropping it closes the lock file, which releases the lock; the lock file itself is never deleted (deleting it would let two copies run, see the plan’s guard section).
- Guard
Builder guard - Options for
Guard. - Guard
Report guard - What the guard did.
- Limit
- A resource limit: soft and hard values,
Nonemeaning unlimited or not applicable. - User
- A user account.
Enums§
- Guard
Warning guard - A condition the guard reports without refusing to start.
Functions§
- guard
guard - Starts the process guard with secure defaults: a single-instance lock in
path-lib’s runtime directory for
name,umask(0o027), and the soft open-file limit raised to 65 536 (at least 1 024 required). Call it before any file is opened and before threads start, and keep theGuardfor the life of the process. - id
- This process’s id.
- is_
elevated - Whether this process runs as root, or with an elevated Administrator token.
- user
- The effective user this process runs as now.