1
0

feat: Initial commit

This commit is contained in:
2024-03-22 16:54:05 +01:00
parent 0d9957a125
commit d993185b89
25 changed files with 641 additions and 0 deletions

30
Lab02/executor.c Normal file
View File

@@ -0,0 +1,30 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#define LEN 128
#define USE_LIB 0
int main(int argc, char ** argv) {
FILE *flist;
if (argc < 2) return 1;
flist = fopen(argv[1], "r");
char cmd[LEN];
while(fgets(cmd, LEN, flist)) {
if (USE_LIB) {
system(cmd);
continue;
}
if (!fork()) {
execl("/bin/sh", "sh", "-c", cmd, (char *) NULL);
} else {
sleep(3);
}
}
return 0;
}