SK/processes/fork.c

25 lines
483 B
C
Raw Normal View History

2023-01-22 22:23:37 +01:00
#include <stdio.h>
#include <sys/types.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
int main(int argc, char *argv[])
{
pid_t pid;
if ((pid = fork()) != -1)
{
if (pid == 0)
{
printf("dziecko\n");
char const *arg[2];
arg[0] = "touch";
arg[1] = "tt";
execvp(arg[0], arg);
}
else
{
waitpid(pid);
printf("rodzic\n");
}
}
}