aboutsummaryrefslogtreecommitdiff
path: root/semestr-5/so/lista1/rozwiazania/ex2b.c
blob: af4a986aa0d6e15ebedfd2341c3b580ff97547f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>

int main() {
  int pid = fork();
  if (pid < 0) {
    printf("Fork error\n");
    exit(1);
  }
  if (pid == 0) {
    printf("[%d], Child process, returning.\n", getpid());
    exit(0);
  }
  else {
    while (1) {
      printf("[%d] Parent process, sleeping.\n", getpid());
      sleep(1);
    }
  }
}