mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 15:48:12 +00:00
logout: Port to LibMain :^)
This commit is contained in:
parent
8b7b726680
commit
ca23644397
2 changed files with 9 additions and 21 deletions
|
@ -76,6 +76,7 @@ target_link_libraries(gzip LibCompress)
|
||||||
target_link_libraries(id LibMain)
|
target_link_libraries(id LibMain)
|
||||||
target_link_libraries(js LibJS LibLine LibMain)
|
target_link_libraries(js LibJS LibLine LibMain)
|
||||||
target_link_libraries(keymap LibKeyboard LibMain)
|
target_link_libraries(keymap LibKeyboard LibMain)
|
||||||
|
target_link_libraries(logout LibMain)
|
||||||
target_link_libraries(lspci LibPCIDB)
|
target_link_libraries(lspci LibPCIDB)
|
||||||
target_link_libraries(lsusb LibUSBDB LibMain)
|
target_link_libraries(lsusb LibUSBDB LibMain)
|
||||||
target_link_libraries(man LibMarkdown)
|
target_link_libraries(man LibMarkdown)
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <LibCore/ProcessStatisticsReader.h>
|
#include <LibCore/ProcessStatisticsReader.h>
|
||||||
|
#include <LibCore/System.h>
|
||||||
|
#include <LibMain/Main.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
static Core::ProcessStatistics const& get_proc(Core::AllProcessesStatistics const& stats, pid_t pid)
|
static Core::ProcessStatistics const& get_proc(Core::AllProcessesStatistics const& stats, pid_t pid)
|
||||||
|
@ -16,24 +18,12 @@ static Core::ProcessStatistics const& get_proc(Core::AllProcessesStatistics cons
|
||||||
VERIFY_NOT_REACHED();
|
VERIFY_NOT_REACHED();
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int, char**)
|
ErrorOr<int> serenity_main(Main::Arguments)
|
||||||
{
|
{
|
||||||
if (pledge("stdio proc rpath", nullptr) < 0) {
|
TRY(Core::System::pledge("stdio proc rpath", nullptr));
|
||||||
perror("pledge");
|
TRY(Core::System::unveil("/proc/all", "r"));
|
||||||
return 1;
|
TRY(Core::System::unveil("/etc/passwd", "r"));
|
||||||
}
|
TRY(Core::System::unveil(nullptr, nullptr));
|
||||||
|
|
||||||
if (unveil("/proc/all", "r") < 0) {
|
|
||||||
perror("unveil");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (unveil("/etc/passwd", "r") < 0) {
|
|
||||||
perror("unveil");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
unveil(nullptr, nullptr);
|
|
||||||
|
|
||||||
// logout finds the highest session up all nested sessions, and kills it.
|
// logout finds the highest session up all nested sessions, and kills it.
|
||||||
auto stats = Core::ProcessStatisticsReader::get_all();
|
auto stats = Core::ProcessStatisticsReader::get_all();
|
||||||
|
@ -53,10 +43,7 @@ int main(int, char**)
|
||||||
sid = parent_sid;
|
sid = parent_sid;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (kill(-sid, SIGTERM) == -1) {
|
TRY(Core::System::kill(-sid, SIGTERM));
|
||||||
perror("kill(2)");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue