init commit

This commit is contained in:
2025-04-13 21:48:15 +03:00
commit 23255e9121
192 changed files with 12200 additions and 0 deletions
+43
View File
@@ -0,0 +1,43 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <wait.h>
#include <sys/types.h>
int
main()
{
pid_t pid;
int n;
pid = fork();
if (!pid) {
for (;;) {
if (scanf("%d", &n) != 1) {
return 0;
}
pid = fork();
if (!pid) {
continue;
}
int status;
wait(&status);
if (pid == -1 || !WIFEXITED(status) || WEXITSTATUS(status)) {
return -1;
}
printf("%d\n", n);
return 0;
}
} else {
int status;
wait(&status);
if (pid == -1 || !WIFEXITED(status) || WEXITSTATUS(status)) {
printf("-1\n");
}
}
return 0;
}