From 7c4d50dccf3080965c202f63aa56439e3824eaf3 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Wed, 25 Apr 2018 21:33:57 +0200 Subject: Revert "Update NSPR to 4.18" This reverts commit 8781f745556be5d7402d0f3adc67ecfe32fe04a0. --- nsprpub/pr/tests/forktest.c | 47 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) (limited to 'nsprpub/pr/tests/forktest.c') diff --git a/nsprpub/pr/tests/forktest.c b/nsprpub/pr/tests/forktest.c index 66dc64575..a389fa479 100644 --- a/nsprpub/pr/tests/forktest.c +++ b/nsprpub/pr/tests/forktest.c @@ -196,6 +196,51 @@ finish: return; } +#ifdef _PR_DCETHREADS + +#include + +pid_t PR_UnixFork1(void) +{ + pid_t parent = getpid(); + int rv = syscall(SYS_fork); + + if (rv == -1) { + return (pid_t) -1; + } else { + /* For each process, rv is the pid of the other process */ + if (rv == parent) { + /* the child */ + return 0; + } else { + /* the parent */ + return rv; + } + } +} + +#elif defined(SOLARIS) + +/* + * It seems like that in Solaris 2.4 one must call fork1() if the + * the child process is going to use thread functions. Solaris 2.5 + * doesn't have this problem. Calling fork() also works. + */ + +pid_t PR_UnixFork1(void) +{ + return fork1(); +} + +#else + +pid_t PR_UnixFork1(void) +{ + return fork(); +} + +#endif /* PR_DCETHREADS */ + int main(int argc, char **argv) { pid_t pid; @@ -205,7 +250,7 @@ int main(int argc, char **argv) DoIO(); - pid = fork(); + pid = PR_UnixFork1(); if (pid == (pid_t) -1) { fprintf(stderr, "Fork failed: errno %d\n", errno); -- cgit v1.2.3