mirror of
https://github.com/hyprwm/hypridle.git
synced 2026-05-08 22:18:11 +02:00
core: use hyprutils CProcess
This commit is contained in:
parent
2ac013387e
commit
24aaf3353c
1 changed files with 5 additions and 28 deletions
|
|
@ -10,6 +10,7 @@
|
|||
#include <algorithm>
|
||||
#include <thread>
|
||||
#include <mutex>
|
||||
#include <hyprutils/os/Process.hpp>
|
||||
|
||||
CHypridle::CHypridle() {
|
||||
m_sWaylandState.display = wl_display_connect(nullptr);
|
||||
|
|
@ -19,19 +20,7 @@ CHypridle::CHypridle() {
|
|||
}
|
||||
}
|
||||
|
||||
static void setupSignals() {
|
||||
struct sigaction sa;
|
||||
|
||||
// don't transform child processes into zombies and don't handle SIGCHLD.
|
||||
sigemptyset(&sa.sa_mask);
|
||||
sa.sa_flags = SA_NOCLDSTOP | SA_NOCLDWAIT | SA_RESTART;
|
||||
sa.sa_handler = SIG_DFL;
|
||||
sigaction(SIGCHLD, &sa, nullptr);
|
||||
}
|
||||
|
||||
void CHypridle::run() {
|
||||
setupSignals();
|
||||
|
||||
m_sWaylandState.registry = makeShared<CCWlRegistry>((wl_proxy*)wl_display_get_registry(m_sWaylandState.display));
|
||||
m_sWaylandState.registry->setGlobal([this](CCWlRegistry* r, uint32_t name, const char* interface, uint32_t version) {
|
||||
const std::string IFACE = interface;
|
||||
|
|
@ -247,25 +236,13 @@ void CHypridle::enterEventLoop() {
|
|||
static void spawn(const std::string& args) {
|
||||
Debug::log(LOG, "Executing {}", args);
|
||||
|
||||
pid_t child = fork();
|
||||
if (child < 0) {
|
||||
Debug::log(ERR, "Failed to fork");
|
||||
Hyprutils::OS::CProcess proc("/bin/sh", {"-c", args});
|
||||
if (!proc.runAsync()) {
|
||||
Debug::log(ERR, "Failed run \"{}\"", args);
|
||||
return;
|
||||
} else if (child == 0) {
|
||||
setsid();
|
||||
|
||||
struct sigaction sa;
|
||||
// reset signals to the default
|
||||
sigemptyset(&sa.sa_mask);
|
||||
sa.sa_flags = 0;
|
||||
sa.sa_handler = SIG_DFL;
|
||||
sigaction(SIGCHLD, &sa, nullptr);
|
||||
|
||||
execl("/bin/sh", "/bin/sh", "-c", args.c_str(), nullptr);
|
||||
_exit(1);
|
||||
}
|
||||
|
||||
Debug::log(LOG, "Process Created with pid {}", child);
|
||||
Debug::log(LOG, "Process Created with pid {}", proc.pid());
|
||||
}
|
||||
|
||||
void CHypridle::onIdled(SIdleListener* pListener) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue