mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 08:27:45 +00:00
CrashDaemon: Port to LibMain :^)
This commit is contained in:
parent
365379bcb1
commit
b3d412d3c1
2 changed files with 6 additions and 11 deletions
|
@ -9,4 +9,4 @@ set(SOURCES
|
||||||
)
|
)
|
||||||
|
|
||||||
serenity_bin(CrashDaemon)
|
serenity_bin(CrashDaemon)
|
||||||
target_link_libraries(CrashDaemon LibC LibCompress LibCore LibCoredump)
|
target_link_libraries(CrashDaemon LibC LibCompress LibCore LibCoredump LibMain)
|
||||||
|
|
|
@ -8,6 +8,8 @@
|
||||||
#include <Kernel/API/InodeWatcherEvent.h>
|
#include <Kernel/API/InodeWatcherEvent.h>
|
||||||
#include <LibCore/FileWatcher.h>
|
#include <LibCore/FileWatcher.h>
|
||||||
#include <LibCore/MappedFile.h>
|
#include <LibCore/MappedFile.h>
|
||||||
|
#include <LibCore/System.h>
|
||||||
|
#include <LibMain/Main.h>
|
||||||
#include <serenity.h>
|
#include <serenity.h>
|
||||||
#include <spawn.h>
|
#include <spawn.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
@ -49,19 +51,12 @@ static void launch_crash_reporter(const String& coredump_path, bool unlink_on_ex
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
ErrorOr<int> serenity_main(Main::Arguments)
|
||||||
{
|
{
|
||||||
if (pledge("stdio rpath wpath cpath proc exec", nullptr) < 0) {
|
TRY(Core::System::pledge("stdio rpath wpath cpath proc exec", nullptr));
|
||||||
perror("pledge");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
Core::BlockingFileWatcher watcher;
|
Core::BlockingFileWatcher watcher;
|
||||||
auto watch_result = watcher.add_watch("/tmp/coredump", Core::FileWatcherEvent::Type::ChildCreated);
|
TRY(watcher.add_watch("/tmp/coredump", Core::FileWatcherEvent::Type::ChildCreated));
|
||||||
if (watch_result.is_error()) {
|
|
||||||
warnln("Failed to watch the coredump directory: {}", watch_result.error());
|
|
||||||
VERIFY_NOT_REACHED();
|
|
||||||
}
|
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
auto event = watcher.wait_for_event();
|
auto event = watcher.wait_for_event();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue