List named semaphores
Asked Answered
V

1

11

Is there a way to list all posix-named-semaphores, ipcs doesn't seem to give any info about posix semaphores e.g. ipcs -s output is

------ Semaphore Arrays --------
key        semid      owner      perms      nsems     
0xcbc384f8 32769      xxx    600        1

Though I have created many posix semaphores and listing `/dev/shm' shows them

-rw------- 1 xxx auniyal 16 2011-08-09 15:59 /dev/shm/sem.mysem
-rw------- 1 auniyal auniyal 16 2011-08-09 16:29 /dev/shm/sem.mysem1
Vesica answered 9/8, 2011 at 22:39 Comment(3)
AFAIK there is no specification on how or where posix named semaphores are implemented. You seem to have found where linux puts them on your own. You can see the name, the owner and the permissions so what further info do you need?Gunthar
@Duck, yes but just wanted to check if there is some official way or command like ipcsVesica
I don't think there is unless a particular OS has created something on their own. OTOH, once you know where to look ls and rm are pretty convenient.Gunthar
V
22

So for now solution seems to be to list /dev/shm e.g.

$ ls -al /dev/shm/sem.*|more
-rw------- 1 auniyal auniyal 16 2011-08-09 15:59 /dev/shm/sem.mysem
-rw------- 1 auniyal auniyal 16 2011-08-09 16:29 /dev/shm/sem.mysem1
-rw------- 1 auniyal auniyal 16 2011-08-09 16:37 /dev/shm/sem.mysem2
-rw------- 1 auniyal auniyal 16 2011-08-09 16:37 /dev/shm/sem.mysem3
-rw------- 1 auniyal auniyal 16 2011-08-09 16:39 /dev/shm/sem.mysem4
...
Vesica answered 10/8, 2011 at 14:36 Comment(1)
You could just as well accept your own answer, as of 2020 it still works in Centos/RHEL 7Levorotation

© 2022 - 2024 — McMap. All rights reserved.