Стартиране на дъщерен процес
#include<sys/types.h>
#include<unistd.h>
pid_t fork(void);
pid_t getpid(void);
pid_t getppid(void);Грешка
Пояснение
fork.c
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
int main(int argc, char * argv[])
{
pid_t pid = fork();
if(pid == -1)
{
printf("Error forking a process!\n");
return EXIT_FAILURE; // return -1
}
else if(pid == 0)
{
printf("Child process!\n");
}
else
{
printf("Parent process!\n");
}
return EXIT_SUCCESS; // return 0
}Last updated