michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: /* michael@0: * Test sproc_p.c michael@0: * michael@0: * The purpose of this test and the sproc_ch.c test is to test the shutdown michael@0: * of all the IRIX sprocs in a program when one of them dies due to an error. michael@0: * michael@0: * In this test, the parent sproc gets a segmentation fault and dies. michael@0: * The child sproc never stops on its own. You should use "ps" to see if michael@0: * the child sproc is killed after the parent dies. michael@0: */ michael@0: michael@0: #include "prinit.h" michael@0: #include michael@0: michael@0: #if !defined(IRIX) michael@0: michael@0: int main(int argc, char **argv) michael@0: { michael@0: printf("This test applies to IRIX only.\n"); michael@0: return 0; michael@0: } michael@0: michael@0: #else /* IRIX */ michael@0: michael@0: #include "prthread.h" michael@0: #include michael@0: #include michael@0: michael@0: void NeverStops(void *unused) michael@0: { michael@0: int i = 0; michael@0: michael@0: printf("The child sproc has pid %d.\n", getpid()); michael@0: printf("The child sproc won't stop on its own.\n"); michael@0: fflush(stdout); michael@0: michael@0: /* I never stop */ michael@0: while (1) { michael@0: i++; michael@0: } michael@0: } michael@0: michael@0: int main() michael@0: { michael@0: int *p = 0; michael@0: michael@0: PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0); michael@0: michael@0: printf("The parent sproc has pid %d.\n", getpid()); michael@0: printf("The parent sproc will first create a child sproc.\n"); michael@0: printf("Then the parent sproc will get a segmentation fault and die.\n"); michael@0: printf("The child sproc should be killed after the parent sproc dies.\n"); michael@0: printf("Use 'ps' to make sure this is so.\n"); michael@0: fflush(stdout); michael@0: michael@0: PR_CreateThread(PR_USER_THREAD, NeverStops, NULL, michael@0: PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD, PR_UNJOINABLE_THREAD, 0); michael@0: michael@0: /* Force a segmentation fault */ michael@0: *p = 0; michael@0: return 0; michael@0: } michael@0: michael@0: #endif /* IRIX */