libzypp  17.23.5
ShutdownLock.cc
Go to the documentation of this file.
1 #include "ShutdownLock_p.h"
2 
3 #include <zypp/ExternalProgram.h>
4 #include <iostream>
5 
6 zypp::ShutdownLock::ShutdownLock(const std::string &reason)
7 {
8  try {
9 
10  std::string whyStr = str::form("--why=%s", reason.c_str());
11 
12  const char* argv[] =
13  {
14  "/usr/bin/systemd-inhibit",
15  "--what=sleep:shutdown:idle",
16  "--who=zypp",
17  "--mode=block",
18  whyStr.c_str(),
19  "/usr/bin/cat",
20  NULL
21  };
22  _prog = shared_ptr<ExternalProgramWithSeperatePgid>( new ExternalProgramWithSeperatePgid( argv, ExternalProgram::Discard_Stderr ) );
23  } catch (...) {
24  }
25 }
26 
28 {
29  if (_prog) {
30  _prog->kill();
31  }
32 }
ShutdownLock_p.h
ExternalProgram.h
zypp::ShutdownLock::~ShutdownLock
~ShutdownLock()
Definition: ShutdownLock.cc:27
zypp::ExternalProgram::kill
bool kill()
Kill the program.
Definition: ExternalProgram.cc:574
zypp::ShutdownLock::ShutdownLock
ShutdownLock(const std::string &reason)
Definition: ShutdownLock.cc:6
zypp::str::form
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
Definition: String.cc:35
zypp::ExternalProgram::Discard_Stderr
Definition: ExternalProgram.h:72
_prog
ExternalProgramWithStderr & _prog
Definition: PluginScript.cc:77
zypp::ExternalProgramWithSeperatePgid
ExternalProgram extended to change the progress group ID after forking.
Definition: ExternalProgram.h:313
zypp::ShutdownLock::_prog
shared_ptr< ExternalProgramWithSeperatePgid > _prog
Definition: ShutdownLock_p.h:38