Date: Sun, 4 May 2014 11:15:23 GMT From: Joris <joris@giovannangeli.fr> To: freebsd-gnats-submit@FreeBSD.org Subject: standards/189353: POSIX sem_unlink does not actually unlink the semaphore in the process context Message-ID: <201405041115.s44BFN71023670@cgiserv.freebsd.org> Resent-Message-ID: <201405041120.s44BK0UO049673@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 189353 >Category: standards >Synopsis: POSIX sem_unlink does not actually unlink the semaphore in the process context >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-standards >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sun May 04 11:20:00 UTC 2014 >Closed-Date: >Last-Modified: >Originator: Joris >Release: freebsd 10 >Organization: >Environment: >Description: When a posix sempahore is open, it is cached in the process address space. A call to sem_unlink does not invalidate the caching, and trying to reopen the semaphore with O_EXCL after calling sem_unlink fails with EEXIST. >How-To-Repeat: Here is a test case : #include <fcntl.h> #include <sys/stat.h> #include <sys/wait.h> #include <sys/types.h> #include <semaphore.h> #include <err.h> int main(int argc, char *argv[]) { sem_t *sem1, *sem2; int error; sem1 = sem_open("/test-sem1", O_CREAT | O_EXCL, S_IRWXU, 1); if (sem1 == SEM_FAILED) err(1,"Cannot create test /test-sem1 semaphore"); error = sem_unlink("/test-sem1"); if (error) err(1, "Cannot unlink semaphore /test-sem1"); sem2 = sem_open("/test-sem1", O_CREAT | O_EXCL, S_IRWXU, 2); if (sem2 == SEM_FAILED) err(1, "Cannot re-create semaphore /test-sem1"); error = sem_unlink("/test-sem1"); if (error) err(1, "Cannot unlink semaphore /test-sem1"); return(0); } >Fix: >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201405041115.s44BFN71023670>