Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool Session::stopX()
- {
- spdlog::info("stopx");
- if (!m_X) {
- spdlog::info("Xorg app is nullptr");
- return false;
- }
- const auto pgidOpt = m_X->pgid();
- if (!pgidOpt) {
- spdlog::info("failed to get pgid for Xorg, some processes may persist after kill");
- return m_X->kill();
- }
- const auto pgid = *pgidOpt; // pgid of app process
- spdlog::info("search for xinit and xorg");
- for (const auto xinit: pids_by_name("xinit")
- | views::filter(_1->*&Pids::pgid == pgid)
- ) {
- spdlog::info("found xinit pid={} pgid={}", xinit.pid, xinit.pgid);
- for (const auto xorg : pids_by_name("Xorg")
- | views::filter(_1->*&Pids::ppid == xinit.pid)
- ) {
- spdlog::info("found Xorg pid={} pgid={}", xorg.pid, xorg.pgid);
- if (kill(-xorg.pgid, SIGKILL) == -1) {
- spdlog::warn("failed to kill Xorg");
- }
- }
- }
- return m_X->kill();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement