semaphores and PID - Linux

This is a discussion on semaphores and PID - Linux ; Hello, I have a problem with a semaphores. It is look like some processes use semaphores, but after they die, they don't return semaphores back to the system. When I checked semaphores with ipcs -s, I noticed that mostly of ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: semaphores and PID

  1. semaphores and PID

    Hello,

    I have a problem with a semaphores. It is look like some processes use
    semaphores, but after they die, they don't return semaphores back to the
    system.

    When I checked semaphores with ipcs -s, I noticed that mostly of them are in
    use by user root (184 out of 190).

    I would like to find which process cause the problem, so I would like to get
    the information, which process (PID) use the semaphore. How can I do that.

    If I use ipcs -s -p I got nothing. It is look like switch -p doesn't work
    for semaphores, only for shared memory.

    I'm using RedHat Advanced Server 2.1.

    Is there any idea, how can I determine PID whcih use semaphore?

    Regards,
    Lovro



  2. Re: semaphores and PID

    "Lovro VREŠ" writes:
    >Hello,
    >
    >I have a problem with a semaphores. It is look like some processes use
    >semaphores, but after they die, they don't return semaphores back to the
    >system.


    None of the system V IPC resources (message queues, semaphores and shared
    memory segments) are automatically returned upon process exit (quite simply
    because they, by definition, are used by more than a single process).

    The process must explicitly call semctl(,,ICP_RMID,) to remove the
    semaphore when it is no longer needed.

    The ipcrm command can be used to clean up after poorly written code or
    in cases where it is not feasible for the application itself to remove
    the semaphore.

    >I would like to find which process cause the problem, so I would like to get
    >the information, which process (PID) use the semaphore. How can I do that.


    If ipcs(1) doesn't give you the information, you'll probably have to start
    poking around in the kernel. Using kdb may
    be of some help.

    If you don't feel comfortable with kdb (for which you'll need to build a
    kernel), you'll have to disable all your services, reboot, then enable and
    start them one at a time checking ipcs(1) between each one, until you
    find the guilty culprit.

    scott

  3. Smile Re: semaphores and PID

    Hi guys,

    Ipcs is a very nice command but has some problems when it comes to semaphores.
    Now back to ur question - how can u get to know the pid which uses the semaphore.

    So first do
    $ ipcs -s
    and get the semid of ur semaphore from the list or if u know it then cool.

    Now do

    $ ipcs -s -i

    and u can see all the info abt the semaphore including the pid also.

    If still the u have any doubts continue the thread

    thanks

    mahesh

+ Reply to Thread