Subject: Re: [QUERY] Help With Semaphore Error on Windows : Cygwin
From: Takashi Yano via Cygwin <[email-masked]>
To: [email-masked]
Cc: Yeo Kai Wei <[email-masked]>
Date: Thu, 16 Feb 2023 20:10:43 +0900
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>

On Thu, 16 Feb 2023 12:04:01 +0800
Yeo Kai Wei wrote:
> Hi All,
> 
> Could I request for some help on some code?
> 
> I ran into an error with semaphores with some book code using Cygwin on 
> Windows.
> 
> The code will throw an error with sem_post().
> 
> I compiled it with gcc -o memwriter memwriter.c -lrt -lpthread
> 
> $ ./memwriter
> Shared memory address: 0x6fffffff0000 [0..511]
> backing file: /dev/shm/shMemEx
> semptr is address 0x7ffffcc18 with value 0
> SEM_VALUE_MAX is 1147483648
> sem_post: Invalid argument <--------------------------- ERROR
> 
> 
> According to feedback, the above error does not turn up on Linux.
> 
> May I know if this is supposed to happen on Cygwin on Windows?
> 
> If not, how can I solve this?
> 
> I've also attached the code for reference.

Semaphore name which does not begin with slash (/) is not
portable.

See:
https://pubs.opengroup.org/onlinepubs/9699919799/functions/sem_open.html

Cygwin disallows that.

-- 
Takashi Yano <[email-masked]>

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