Back to index

courier  0.68.2
Defines | Functions | Variables
confwait.c File Reference
#include <sys/types.h>
#include <stdio.h>
#include <signal.h>
#include <string.h>
#include <time.h>
#include "waitlib.c"

Go to the source code of this file.

Defines

#define INCLUDED_FROM_CONFIGURE
#define NUMPROCS   10

Functions

static void cntreaped (pid_t p, int n)
static RETSIGTYPE childsig (int n)
int main ()

Variables

static int numterminated = 0

Define Documentation

Definition at line 24 of file confwait.c.

#define NUMPROCS   10

Definition at line 27 of file confwait.c.


Function Documentation

static RETSIGTYPE childsig ( int  n) [static]

Definition at line 37 of file confwait.c.

{
       n=n;

       wait_reap(cntreaped, childsig);

#if    RETSIGTYPE != void
       return (0);
#endif
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void cntreaped ( pid_t  p,
int  n 
) [static]

Definition at line 32 of file confwait.c.

{
       if ( ++numterminated == NUMPROCS ) _exit(0);
}

Here is the caller graph for this function:

int main ( )

Definition at line 48 of file confwait.c.

{
int    pipefd[2];
int    pipefd2[2];
pid_t  p;
int    i;
time_t t;
char   c;

       if (pipe(pipefd) || pipe(pipefd2))
       {
              perror("pipe");
              exit(1);
       }

       signal(SIGCHLD, childsig);

       for (i=0; i<NUMPROCS; i++)
       {
              while ((p=fork()) == -1)
              {
                     perror("fork");
                     sleep(5);
              }

              if (p == 0)
              {
                     close(pipefd[1]);
                     close(pipefd2[0]);
                     close(pipefd2[1]);
                     read(pipefd[0], &c, 1);
                     _exit(0);
              }
       }
       close(pipefd2[1]);
       close(pipefd[0]);
       if (read(pipefd2[0], &c, 1) != 0)
       {
              perror("read");
       }

       wait_block();

       close(pipefd2[0]);
       close(pipefd[1]);
       sleep(3);
       time(&t);
       wait_clear(&childsig);

       do
       {
              sleep(3);
       } while ( time(0) < t+3);
       if (numterminated == NUMPROCS)
              exit(0);
       exit(1);
       return (0);
}

Here is the call graph for this function:


Variable Documentation

int numterminated = 0 [static]

Definition at line 29 of file confwait.c.