Files
KirkOS/user/include/mlibc/helloworld.c
T
2026-05-18 04:02:59 -04:00

34 lines
646 B
C

#include <unistd.h>
#include <sys/wait.h>
#include <stdio.h>
int main() {
printf("\nforking!");
pid_t pid = fork();
if (pid < 0) {
perror("fork failed");
return 1;
}
if (pid == 0) {
// Child process
printf("child processed!");
char *argv[] = {"/bin/pwd", NULL};
char *envp[] = {NULL};
execve("/bin/pwd", argv, envp);
// If execve returns, it failed
perror("execve failed");
return 1;
} else {
// Parent process
waitpid(pid, NULL, 0);
printf("Child process finished\n");
}
printf("comp");
return 0;
}