This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: Win32 error in C program using openmp and fork()
- From: Corinna Vinschen <corinna-cygwin at cygwin dot com>
- To: cygwin at cygwin dot com
- Date: Mon, 22 Jul 2013 10:06:57 +0200
- Subject: Re: Win32 error in C program using openmp and fork()
- References: <57302C57257EF2428CCAAF9BA83EC0448222C0EA at mbx08 dot adf dot bham dot ac dot uk>
- Reply-to: cygwin at cygwin dot com
On Jul 20 19:30, 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 didn't try with 1.7.20, but with the current 1.7.21 and with the
latest snapshot from http://cygwin.com/snapshots/, on 32 and 64 bit,
and this is what I get on both cases:
$ uname -r
1.7.21(0.267/5/3)
$ gcc -g -fopenmp -o openmp-test openmp-test.c
$ ./openmp-test
I'm an openmp thread...
I'm an openmp thread...
Parent fork
Child fork
$
Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
Red Hat
--
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