backout 29799f914cab, Bug 917642 - [Helix] Please update the helix blobs
[gecko.git] / nsprpub / pr / tests / sproc_p.c
blob8911f1f5b9e51da1cca56cf5cea4c13d1b21e675
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 /*
7 * Test sproc_p.c
9 * The purpose of this test and the sproc_ch.c test is to test the shutdown
10 * of all the IRIX sprocs in a program when one of them dies due to an error.
12 * In this test, the parent sproc gets a segmentation fault and dies.
13 * The child sproc never stops on its own. You should use "ps" to see if
14 * the child sproc is killed after the parent dies.
17 #include "prinit.h"
18 #include <stdio.h>
20 #if !defined(IRIX)
22 int main(int argc, char **argv)
24 printf("This test applies to IRIX only.\n");
25 return 0;
28 #else /* IRIX */
30 #include "prthread.h"
31 #include <sys/types.h>
32 #include <unistd.h>
34 void NeverStops(void *unused)
36 int i = 0;
38 printf("The child sproc has pid %d.\n", getpid());
39 printf("The child sproc won't stop on its own.\n");
40 fflush(stdout);
42 /* I never stop */
43 while (1) {
44 i++;
48 int main()
50 int *p = 0;
52 PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);
54 printf("The parent sproc has pid %d.\n", getpid());
55 printf("The parent sproc will first create a child sproc.\n");
56 printf("Then the parent sproc will get a segmentation fault and die.\n");
57 printf("The child sproc should be killed after the parent sproc dies.\n");
58 printf("Use 'ps' to make sure this is so.\n");
59 fflush(stdout);
61 PR_CreateThread(PR_USER_THREAD, NeverStops, NULL,
62 PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD, PR_UNJOINABLE_THREAD, 0);
64 /* Force a segmentation fault */
65 *p = 0;
66 return 0;
69 #endif /* IRIX */