Cod sursa(job #2480253)
| Utilizator | Data | 25 octombrie 2019 09:48:58 | |
|---|---|---|---|
| Problema | Aria | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.49 kb |
include <unistd.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/wait.h>
int main(int argc, char* argv[])
{
int pid = fork(), errno=-1;
if(pid<0)
return errno;
else if(pid==0)
{
char *argv[]={"ls",NULL};
// printf("%d %d",getppid(),pid);
execve("/bin/ls",argv,NULL);
perror(NULL);
printf("Child");
}else {
printf("Parent id %d \n CHild id %d\n\n",getppid(),pid);
wait(NULL);
printf("Parent");
}
}
