nsprpub/pr/tests/sproc_p.c

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     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
     8  *
     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.
    11  *
    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.
    15  */
    17 #include "prinit.h"
    18 #include <stdio.h>
    20 #if !defined(IRIX)
    22 int main(int argc, char **argv)
    23 {
    24     printf("This test applies to IRIX only.\n");
    25     return 0;
    26 }
    28 #else  /* IRIX */
    30 #include "prthread.h"
    31 #include <sys/types.h>
    32 #include <unistd.h>
    34 void NeverStops(void *unused)
    35 {
    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++;
    45     }
    46 }
    48 int main()
    49 {
    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;
    67 }
    69 #endif /* IRIX */

mercurial