diff --git a/Userland/Applications/Assistant/main.cpp b/Userland/Applications/Assistant/main.cpp index 3655a4adc1..703d843aa9 100644 --- a/Userland/Applications/Assistant/main.cpp +++ b/Userland/Applications/Assistant/main.cpp @@ -7,6 +7,7 @@ #include "Providers.h" #include #include +#include #include #include #include @@ -17,6 +18,7 @@ #include #include #include +#include #include namespace Assistant { @@ -191,11 +193,23 @@ static constexpr size_t MAX_SEARCH_RESULTS = 6; int main(int argc, char** argv) { - if (pledge("stdio recvfd sendfd rpath unix proc exec thread", nullptr) < 0) { + if (pledge("stdio recvfd sendfd rpath cpath unix proc exec thread", nullptr) < 0) { perror("pledge"); return 1; } + Core::LockFile lockfile("/tmp/lock/assistant.lock"); + + if (!lockfile.is_held()) { + if (lockfile.error_code()) { + warnln("Core::LockFile: {}", strerror(lockfile.error_code())); + return 1; + } + + // Another assistant is open, so exit silently. + return 0; + } + auto app = GUI::Application::construct(argc, argv); auto window = GUI::Window::construct(); window->set_minimizable(false);