Nix 2.36.0
Nix, the purely functional package manager; unstable internal interfaces
Loading...
Searching...
No Matches
nix::Pid Class Reference

Public Member Functions

 Pid (const Pid &)=delete
 Pid (Pid &&other) noexcept
Pid & operator= (const Pid &)=delete
Pid & operator= (Pid &&other) noexcept
 Pid (pid_t pid)
void operator= (pid_t pid)
 operator pid_t () const
 operator bool () const noexcept
int kill (bool allowInterrupts=true)
int wait (bool allowInterrupts=true)
void setSeparatePG (bool separatePG)
void setKillSignal (int signal)
void setKillTimeout (std::chrono::milliseconds duration)
pid_t release ()

Friends

void swap (Pid &lhs, Pid &rhs) noexcept

Member Function Documentation

◆ operator bool()

nix::Pid::operator bool ( ) const
explicitnoexcept

Whether this holds a child at all, as opposed to having been default-constructed, moved from, or waited for.

Note
On Unix Pid also has an implicit operator pid_t. This wins overload resolution over it only because both are const: bool is an exact match where pid_t needs a further boolean conversion. If operator pid_t is ever made non-const it becomes the better match for a non-const Pid, which is nearly all of them, and then every if (pid) silently means pid != 0 – true for a Pid holding no child – with no diagnostic. Measured: with a non-const operator pid_t, both if (pid) and static_cast<bool>(pid) select it.

The documentation for this class was generated from the following files:
  • libutil/include/nix/util/processes.hh
  • libutil/processes.cc
  • libutil/unix/processes.cc
  • libutil/windows/processes.cc