LCOV - code coverage report
Current view: top level - tests - t-fork.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 13 15 86.7 %
Date: 2016-09-12 12:21:20 Functions: 1 1 100.0 %

          Line data    Source code
       1             : /* t-fork.c
       2             :  * Copyright 2016 g10 Code GmbH
       3             :  *
       4             :  * This file is free software; as a special exception the author gives
       5             :  * unlimited permission to copy and/or distribute it, with or without
       6             :  * modifications, as long as this notice is preserved.
       7             :  *
       8             :  * This file is distributed in the hope that it will be useful, but
       9             :  * WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
      10             :  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
      11             :  */
      12             : 
      13             : #include <sys/types.h>
      14             : #include <sys/wait.h>
      15             : #include <unistd.h>
      16             : #include "t-support.h"
      17             : 
      18             : 
      19             : int
      20           1 : main (int argc, const char *argv[])
      21             : {
      22             :   int rc;
      23             :   pid_t pid;
      24             : 
      25           1 :   if (argc >= 2 && !strcmp (argv[1], "--verbose"))
      26           0 :     opt_verbose = 1;
      27             : 
      28           1 :   rc = npth_init ();
      29           1 :   fail_if_err (rc);
      30             : 
      31           1 :   pid = fork ();
      32           2 :   if (pid == (pid_t)-1)
      33           0 :     fail_msg ("fork failed");
      34           2 :   else if (pid)
      35             :    {
      36             :      int status;
      37             : 
      38           1 :      info_msg ("forked");
      39           1 :      wait (&status);
      40           1 :      fail_if_err (status);
      41             :    }
      42             :   else
      43             :     {
      44           1 :       info_msg ("child exit");
      45           1 :       npth_usleep (1000);     /* Let NPTH enter, sleep, and leave.  */
      46             :     }
      47             : 
      48           2 :   return 0;
      49             : }

Generated by: LCOV version 1.11