Serenity Operating System
1#include <stdio.h>
2#include <stdlib.h>
3#include <sys/wait.h>
4#include <unistd.h>
5
6int main(int argc, char** argv)
7{
8 if (argc < 3) {
9 printf("usage: flock <path> <command...>\n");
10 return 0;
11 }
12
13 if (!fork()) {
14 if (execvp(argv[2], &argv[2]) < 0) {
15 perror("execvp");
16 exit(1);
17 }
18 }
19
20 int status;
21 if (waitpid(-1, &status, 0) < 0) {
22 perror("waitpid");
23 return 1;
24 }
25 return WEXITSTATUS(status);
26}