This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: problem with mmap and fork()
- From: Glyn Gowing <lzq dot maillist at gmail dot com>
- To: cygwin at cygwin dot com
- Date: Sat, 23 Feb 2019 15:50:25 -0600
- Subject: Re: problem with mmap and fork()
- References: <CAAoGPJzdYcCDB=J4ZdfDq1xwLYvZBmT1rC937xHjMd8vseZ-=A@mail.gmail.com> <CAJ1FpuNG7a2nrK0A90VKuT9dAe5pf+aRbJzr65=cgQMxQ8rsuQ@mail.gmail.com>
Thanks for confirming for me that cygwin can't do this with fork().
I guess I'll have to warn them about this difference in cygwin. I was
hoping I had made a mistake somewhere.
On Sat, Feb 23, 2019 at 6:54 AM Doug Henderson <djndnbvg@gmail.com> wrote:
>
> On Fri, 22 Feb 2019 at 17:01, Glyn Gowing <> wrote:
> > I have a program (attached) that works correctly on my mac but does
> > not work with Cygwin on Windows 10. I'm running the latest version of
>
> > What happens in the buggy execution is that the child obtains a lock
> > before the parent releases it. I'm using mmap and a pthread_mutex_t
> > object along with fork(). Again, this exact code works correctly on my
> > Mac running Mojave.
>
> On further analysis, the call to
> > pthread_mutexattr_setpshared(attr, PTHREAD_PROCESS_SHARED);
> is failing. The error is EINVAL (22) Invalid argument.
>
> This suggests that pthread mutexes cannot be shared between processes
> by using shared memory in cygwin. I have not attempted to determine if
> this is working as expected, or if this is a bug, or a limitation in
> the Windows environment.
>
> I have attached my files:
> smtest2.c - my heavily modified version of OP's original.
> smtest2.txt - output from running this version.showing error.
> smtest3.c - my version which uses 2 pthreads in a single process
> smtest3.txt - output from running this version, showing OP's expected results.
>
> HTH
> Doug
>
> --
> 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
--
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