#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
int main() {
printf("Loader PID: %d. Before exec...\n", getpid());
execlp("/bin/ls", "ls", "-l", NULL); // запускаем ls -l
// Всё, что ниже, выполнится только при ошибке exec
perror("execlp");
printf("This line appears only on error.\n");
return 1;
}
==============================================
#include <stdio.h>
#include <unistd.h>
int main() {
printf("Target PID: %d. Hello from a separate program!\n", getpid());
return 0;
}