Skip to content

Commit

Permalink
Userland: Add a dummy passthrough "flock" program
Browse files Browse the repository at this point in the history
This allows you to run our build system's Makefiles inside SerenityOS
itself (since they rely on "flock")

Obviously it doesn't do any locking as we don't support that yet.
  • Loading branch information
awesomekling committed Jan 20, 2020
1 parent f4f958f commit e711936
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions Userland/flock.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#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;
}

if (!fork()) {
if (execvp(argv[2], &argv[2]) < 0) {
perror("execvp");
exit(1);
}
}

int status;
if (waitpid(-1, &status, 0) < 0) {
perror("waitpid");
return 1;
}
return WEXITSTATUS(status);
}

0 comments on commit e711936

Please sign in to comment.