1f08c3bdfSopenharmony_ci/* 2f08c3bdfSopenharmony_ci * Copyright (c) International Business Machines Corp., 2001 3f08c3bdfSopenharmony_ci * 4f08c3bdfSopenharmony_ci * This program is free software; you can redistribute it and/or modify 5f08c3bdfSopenharmony_ci * it under the terms of the GNU General Public License as published by 6f08c3bdfSopenharmony_ci * the Free Software Foundation; either version 2 of the License, or 7f08c3bdfSopenharmony_ci * (at your option) any later version. 8f08c3bdfSopenharmony_ci * 9f08c3bdfSopenharmony_ci * This program is distributed in the hope that it will be useful, 10f08c3bdfSopenharmony_ci * but WITHOUT ANY WARRANTY; without even the implied warranty of 11f08c3bdfSopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See 12f08c3bdfSopenharmony_ci * the GNU General Public License for more details. 13f08c3bdfSopenharmony_ci * 14f08c3bdfSopenharmony_ci * You should have received a copy of the GNU General Public License 15f08c3bdfSopenharmony_ci * along with this program. 16f08c3bdfSopenharmony_ci * 17f08c3bdfSopenharmony_ci * History 18f08c3bdfSopenharmony_ci * 07/2001 John George 19f08c3bdfSopenharmony_ci * -Ported 20f08c3bdfSopenharmony_ci * 04/2002 wjhuie sigset cleanups 21f08c3bdfSopenharmony_ci */ 22f08c3bdfSopenharmony_ci 23f08c3bdfSopenharmony_ci/* 24f08c3bdfSopenharmony_ci * DESCRIPTION 25f08c3bdfSopenharmony_ci * Tests to see if pids returned from fork and waitpid are same. 26f08c3bdfSopenharmony_ci * 27f08c3bdfSopenharmony_ci * ALGORITHM 28f08c3bdfSopenharmony_ci * Check proper functioning of waitpid with pid = -1 and arg = 0 29f08c3bdfSopenharmony_ci */ 30f08c3bdfSopenharmony_ci 31f08c3bdfSopenharmony_ci#include "waitpid_common.h" 32f08c3bdfSopenharmony_ci 33f08c3bdfSopenharmony_cistatic void do_child_1(void) 34f08c3bdfSopenharmony_ci{ 35f08c3bdfSopenharmony_ci pid_t pid; 36f08c3bdfSopenharmony_ci int i; 37f08c3bdfSopenharmony_ci 38f08c3bdfSopenharmony_ci for (i = 0; i < MAXKIDS; i++) { 39f08c3bdfSopenharmony_ci if (i == (MAXKIDS / 2)) 40f08c3bdfSopenharmony_ci SAFE_SETPGID(0, 0); 41f08c3bdfSopenharmony_ci 42f08c3bdfSopenharmony_ci pid = SAFE_FORK(); 43f08c3bdfSopenharmony_ci if (pid == 0) 44f08c3bdfSopenharmony_ci do_exit(0); 45f08c3bdfSopenharmony_ci 46f08c3bdfSopenharmony_ci fork_kid_pid[i] = pid; 47f08c3bdfSopenharmony_ci } 48f08c3bdfSopenharmony_ci 49f08c3bdfSopenharmony_ci TST_CHECKPOINT_WAKE2(0, MAXKIDS); 50f08c3bdfSopenharmony_ci 51f08c3bdfSopenharmony_ci if (TST_TRACE(reap_children(-1, 0, fork_kid_pid, MAXKIDS))) 52f08c3bdfSopenharmony_ci return; 53f08c3bdfSopenharmony_ci 54f08c3bdfSopenharmony_ci tst_res(TPASS, "Test PASSED"); 55f08c3bdfSopenharmony_ci} 56f08c3bdfSopenharmony_ci 57f08c3bdfSopenharmony_cistatic struct tst_test test = { 58f08c3bdfSopenharmony_ci .forks_child = 1, 59f08c3bdfSopenharmony_ci .needs_checkpoints = 1, 60f08c3bdfSopenharmony_ci .setup = waitpid_setup, 61f08c3bdfSopenharmony_ci .cleanup = waitpid_cleanup, 62f08c3bdfSopenharmony_ci .test_all = waitpid_test, 63f08c3bdfSopenharmony_ci}; 64