Search notes:

libc: wait

#include <sys/wait.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>

void child() {

  for (int i=0; i<5; i++) {
    sleep(1);
    printf("%d\n", i);
  }
  exit(0);

}
void parent(pid_t pid_child) {
  int status;

  waitpid(pid_child, &status, 0);
  printf("child exited, status = %d\n", status);

}

int main() {

  pid_t pid = fork();

  if      (pid == 0) child ();
  else if (pid  > 0) parent(pid);
  else     printf("fork failed\n");

}
Github repository about-libc, path: /wait/waitpid.c

See also

The Standard C Library

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1758201003, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/C-C-plus-plus/C/libc/wait(68): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78