/* * Copyright (c) 2020, Andreas Kling * * SPDX-License-Identifier: BSD-2-Clause */ #include #include #include #include #include #include #include int main(int argc, char** argv) { if (argc < 3) { warnln("usage: flock "); return 1; } pid_t child_pid; if ((errno = posix_spawnp(&child_pid, argv[2], nullptr, nullptr, &argv[2], environ))) { perror("posix_spawn"); return 1; } int status; if (waitpid(child_pid, &status, 0) < 0) { perror("waitpid"); return 1; } return WEXITSTATUS(status); }