Serenity Operating System
at master 24 lines 626 B view raw
1/* 2 * Copyright (c) 2020, Andreas Kling <kling@serenityos.org> 3 * 4 * SPDX-License-Identifier: BSD-2-Clause 5 */ 6 7#include <AK/Format.h> 8#include <LibCore/System.h> 9#include <LibMain/Main.h> 10#include <sys/wait.h> 11#include <unistd.h> 12 13ErrorOr<int> serenity_main(Main::Arguments arguments) 14{ 15 if (arguments.strings.size() < 3) { 16 warnln("usage: flock <path> <command...>"); 17 return 1; 18 } 19 20 pid_t child_pid = TRY(Core::System::posix_spawnp(arguments.strings[2], nullptr, nullptr, &arguments.argv[2], environ)); 21 auto [_, status] = TRY(Core::System::waitpid(child_pid)); 22 23 return WEXITSTATUS(status); 24}