Win32 error in C program using openmp and fork()

Larry Hall (Cygwin) reply-to-list-only-lh@cygwin.com
Sun Jul 21 07:10:00 GMT 2013


On 7/20/2013 3:30 PM, Daniel Brown wrote:
> Hi,
>
> So I have some code I am trying to port to Cygwin but I am getting the
> error:
>
> fatal error in forked process - failed to create new win32 semaphore,
> Win32 error 87
>
> when calling fork() in a C program when openmp code has been used
> beforehand. I've got the following test code which reduces the problem
> down to as little code as I could:
>
> #include <stdio.h>
> #include <omp.h>
> #include <sys/types.h>
>
> int main(void)
> {
>       pid_t childPID;
>
>       #pragma omp parallel
>       {
>           printf("I'm an openmp thread...\n");
>       }
>
>       childPID =3D fork();
>
>       if(childPID >=3D 0) {
>           if(childPID =3D=3D 0) {
>               printf("Child fork\n");
>           } else {
>               printf("Parent fork\n");
>           }
>       } else {
>           printf("Fork failed");
>           return 1;
>       }
>
>       return 0;
> }
>
> To build I just use "gcc -fopenmp para.c" and the output I get is...
>
> I'm an openmp thread...
> I'm an openmp thread...
> I'm an openmp thread...
> I'm an openmp thread...
> Parent fork 0 [main] a 18640 D:\usr\code\c\a.exe: *** fatal error
> in forked process - failed to create new win32 semaphore, Win32 error
> 87
>
> I have tried doing a rebaseall as I had similar error in the past but it
> didn't fix it. I have also tried a clean install on a separate Windows
> 2008 R2 machine which didn't work either.
>
> The version of GCC is 4.7.3 and I am on Windows 8 Professional
> 64-bit, Cygwin 1.7.20(0.266/5/3).

Please send cygcheck output as requested at the link below:

> Problem reports:       http://cygwin.com/problems.html

-- 
Larry

_____________________________________________________________________

A: Yes.
 > Q: Are you sure?
 >> A: Because it reverses the logical flow of conversation.
 >>> Q: Why is top posting annoying in email?

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple



More information about the Cygwin mailing list