release method

  1. @override
Future<void> release()
override

Drops the assertion. Safe to call more than once.

Implementation

@override
Future<void> release() async {
  if (_released) return;
  _released = true;
  // SIGTERM the helper: caffeinate drops its assertion, systemd-inhibit
  // ends the inhibition. kill() on an already-dead child is a no-op.
  _process.kill();
  try {
    await _exit.timeout(killTimeout);
  } on TimeoutException {
    // The helper ignored SIGTERM: escalate to SIGKILL, then proceed —
    // release must return even when the helper refuses to die.
    _process.kill(ProcessSignal.sigkill);
  }
}