mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 09:30:24 +00:00
flock: Port to LibMain
This commit is contained in:
parent
11578c623c
commit
160f3224a5
Notes:
sideshowbarker
2024-07-17 22:43:48 +09:00
Author: https://github.com/kennethmyhra Commit: https://github.com/SerenityOS/serenity/commit/160f3224a5a Pull-request: https://github.com/SerenityOS/serenity/pull/11253 Reviewed-by: https://github.com/alimpfard Reviewed-by: https://github.com/bgianfo ✅
2 changed files with 7 additions and 15 deletions
|
@ -90,6 +90,7 @@ target_link_libraries(expr LibRegex)
|
||||||
target_link_libraries(fdtdump LibDeviceTree LibMain)
|
target_link_libraries(fdtdump LibDeviceTree LibMain)
|
||||||
target_link_libraries(file LibGfx LibIPC LibCompress LibMain)
|
target_link_libraries(file LibGfx LibIPC LibCompress LibMain)
|
||||||
target_link_libraries(find LibMain)
|
target_link_libraries(find LibMain)
|
||||||
|
target_link_libraries(flock LibMain)
|
||||||
target_link_libraries(fortune LibMain)
|
target_link_libraries(fortune LibMain)
|
||||||
target_link_libraries(functrace LibDebug LibX86)
|
target_link_libraries(functrace LibDebug LibX86)
|
||||||
target_link_libraries(gml-format LibGUI)
|
target_link_libraries(gml-format LibGUI)
|
||||||
|
|
|
@ -5,30 +5,21 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <AK/Format.h>
|
#include <AK/Format.h>
|
||||||
#include <errno.h>
|
#include <LibCore/System.h>
|
||||||
#include <spawn.h>
|
#include <LibMain/Main.h>
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
{
|
{
|
||||||
if (argc < 3) {
|
if (arguments.strings.size() < 3) {
|
||||||
warnln("usage: flock <path> <command...>");
|
warnln("usage: flock <path> <command...>");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
pid_t child_pid;
|
pid_t child_pid = TRY(Core::System::posix_spawnp(arguments.strings[2], nullptr, nullptr, &arguments.argv[2], environ));
|
||||||
if ((errno = posix_spawnp(&child_pid, argv[2], nullptr, nullptr, &argv[2], environ))) {
|
int status = TRY(Core::System::waitpid(child_pid, &status, 0));
|
||||||
perror("posix_spawn");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int status;
|
|
||||||
if (waitpid(child_pid, &status, 0) < 0) {
|
|
||||||
perror("waitpid");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return WEXITSTATUS(status);
|
return WEXITSTATUS(status);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue