void init_child(int childno) { cpu_set_t set; pid_t pid = getpid(); this_child = childno; set_seed(childno); shm->kill_count[childno] = 0; disable_coredumps(); if (sched_getaffinity(pid, sizeof(set), &set) == 0) { CPU_ZERO(&set); CPU_SET(childno, &set); sched_setaffinity(pid, sizeof(set), &set); } shm->child_syscall_count[childno] = 0; set_make_it_fail(); if (rand() % 100 < 50) use_fpu(); shm->num_mappings[childno] = 0; shm->mappings[childno] = zmalloc(sizeof(struct map)); INIT_LIST_HEAD(&shm->mappings[childno]->list); }
void init_child(int childno) { cpu_set_t set; pid_t pid = getpid(); char childname[17]; this_child = childno; set_seed(childno); shm->kill_count[childno] = 0; shm->num_mappings[childno] = 0; shm->mappings[childno] = zmalloc(sizeof(struct map)); INIT_LIST_HEAD(&shm->mappings[childno]->list); setup_page_maps(); if (sched_getaffinity(pid, sizeof(set), &set) == 0) { CPU_ZERO(&set); CPU_SET(childno, &set); sched_setaffinity(pid, sizeof(set), &set); } shm->child_syscall_count[childno] = 0; memset(childname, 0, sizeof(childname)); sprintf(childname, "trinity-c%d", childno); prctl(PR_SET_NAME, (unsigned long) &childname); oom_score_adj(500); /* Wait for parent to set our pidslot */ while (shm->pids[childno] != getpid()) { int ret = 0; /* Make sure parent is actually alive to wait for us. */ ret = pid_alive(shm->mainpid); if (ret != 0) { shm->exit_reason = EXIT_SHM_CORRUPTION; outputerr(BUGTXT "parent (%d) went away!\n", shm->mainpid); sleep(20000); } } /* Wait for all the children to start up. */ while (shm->ready == FALSE) sleep(1); set_make_it_fail(); if (rand() % 100 < 50) use_fpu(); mask_signals_child(); disable_coredumps(); }