Example #1
0
main(int argc, char **argv)
{
int c=0, FatherStatus;

init_signals();

    while (1) {
        int option_index = 0;
        c = getopt(argc, argv, "n:");

        if (c == -1)
            break;

        switch (c) {

        case 'n':
            OPTIONS.NCORES=atoi(optarg);
            break;

        default:
            usage(argv[0]);
        }
    }

    printf("Number of children to be started : %d\n",(int)OPTIONS.NCORES);
    start_children(Index,OPTIONS.NCORES);
    handle_sigterm();
    wait(&FatherStatus);

}
Example #2
0
File: stud.c Project: gyepisam/stud
/* Forks a new child to replace the old, dead, one with the given PID.*/
void replace_child_with_pid(pid_t pid) {
  int i;

  /* find old child's slot and put a new child there */ 
  for (i = 0; i < OPTIONS.NCORES; i++) {
    if (child_pids[i] == pid) {
      start_children(i, 1);
      return;
    }
  }

  ERR("Cannot find index for child pid %d", pid);
}