Skip to content

Commit 2010a43

Browse files
committed
Cope with case that SEM_FAILED is not defined (assume failure code is -1)
1 parent 8df5625 commit 2010a43

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/backend/port/posix_sema.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* Portions Copyright (c) 1994, Regents of the University of California
1212
*
1313
* IDENTIFICATION
14-
* $Header: /cvsroot/pgsql/src/backend/port/posix_sema.c,v 1.2 2002/05/05 01:03:26 tgl Exp $
14+
* $Header: /cvsroot/pgsql/src/backend/port/posix_sema.c,v 1.3 2002/05/05 16:01:50 tgl Exp $
1515
*
1616
*-------------------------------------------------------------------------
1717
*/
@@ -72,8 +72,14 @@ PosixSemaphoreCreate(void)
7272

7373
mySem = sem_open(semname, O_CREAT | O_EXCL,
7474
(mode_t) IPCProtection, (unsigned) 1);
75+
76+
#ifdef SEM_FAILED
7577
if (mySem != (sem_t *) SEM_FAILED)
7678
break;
79+
#else
80+
if (mySem != (sem_t *) (-1))
81+
break;
82+
#endif
7783

7884
/* Loop if error indicates a collision */
7985
if (errno == EEXIST || errno == EACCES || errno == EINTR)
@@ -82,7 +88,7 @@ PosixSemaphoreCreate(void)
8288
/*
8389
* Else complain and abort
8490
*/
85-
fprintf(stderr, "PosixSemaphoreCreate: sem_open(%s) failed: %s\n",
91+
fprintf(stderr, "PosixSemaphoreCreate: sem_open(\"%s\") failed: %s\n",
8692
semname, strerror(errno));
8793
proc_exit(1);
8894
}

0 commit comments

Comments
 (0)