Exemplo n.º 1
0
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);
}
Exemplo n.º 2
0
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();
}
Exemplo n.º 3
0
int main(void)
{
  int status;

  start(62);
  subtest = 0;

  signal(SIGUSR1, (void (*)(int)) handler);

  /* Initialize the FPU state. This state is inherited, too. */
  use_fpu(-1);

  for (count = 0; count <= 255; count++) {
	switch (fork()) {
	case -1:
		e(1);

		break;

	case 0:
		signal(SIGFPE, crashed);

		/* Load bad state into the kernel. */
		if (kill(getpid(), SIGUSR1)) e(2);

		/* Let the kernel restore the state. */
		use_fpu(count);

		exit(EXIT_SUCCESS);

	default:
		/* We cannot tell exactly whether what happened is correct or
		 * not -- certainly not in a platform-independent way. However,
		 * if the whole system keeps running, that's good enough.
		 */
		(void) wait(&status);
	}
  }

  if (state <= 1.4 || state >= 1.6) e(3);

  quit();
}