Skip to content

Commit 88833b4

Browse files
authored
Update posix.go
1 parent 38a1437 commit 88833b4

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

sem/posix.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ func Open(name string, value uint) (*Sem, error) {
3030
cName := C.CString(name)
3131
defer C.free(unsafe.Pointer(cName))
3232

33-
sem := C.sem_open_wrapper(cName, C.O_CREAT|C.O_EXCL, C.S_IRUSR|C.S_IWUSR, C.uint(value))
33+
// Remove O_EXCL flag to allow opening an existing semaphore.
34+
sem := C.sem_open_wrapper(cName, C.O_CREAT, C.S_IRUSR|C.S_IWUSR, C.uint(value))
3435
if sem == C.SEM_FAILED {
3536
return nil, errors.New("failed to open semaphore")
3637
}
@@ -45,6 +46,8 @@ func (s *Sem) Wait() error {
4546
return nil
4647
}
4748

49+
50+
4851
// Post increases the semaphore value (unlock/post).
4952
func (s *Sem) Post() error {
5053
if C.sem_post(s.sem) == -1 {

0 commit comments

Comments
 (0)