#include "stdio.h"
#include "stdlib.h"
#include "unistd.h"
int main () {
pid_t pid;
pid = fork();
if (pid == -1) {
perror("fork error");
exit(1);
} else if (pid > 0) {
printf("I'm parent\n");
} else if (pid == 0) {
printf("I'm child\n");
// NULL: the end of args
execl("/bin/ls", "ls", "-l", NULL);
// if success will not back , in other words , exec next code only on failure
perror("child exec failure");
exit(1);
}
return 0;
}