mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-24 10:22:05 -05:00
1682f0b760
SPDX License Identifiers are a more compact / standardized way of representing file license information. See: https://spdx.dev/resources/use/#identifiers This was done with the `ambr` search and replace tool. ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
32 lines
662 B
C++
32 lines
662 B
C++
/*
|
|
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <spawn.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <sys/wait.h>
|
|
#include <unistd.h>
|
|
|
|
int main(int argc, char** argv)
|
|
{
|
|
if (argc < 3) {
|
|
printf("usage: flock <path> <command...>\n");
|
|
return 0;
|
|
}
|
|
|
|
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);
|
|
}
|