To know if a process is attached tho some segment of shared memory - HP UX

This is a discussion on To know if a process is attached tho some segment of shared memory - HP UX ; HP-UX B.11.23 U ia64 Struct pst_shminfo contains member psh_nattch; /* current # of procs attached (accurate)*/ Is it possible to know pid's of those processes? Sub-question. Is it possible to know if current process is attached tho some segment of ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: To know if a process is attached tho some segment of shared memory

  1. To know if a process is attached tho some segment of shared memory

    HP-UX B.11.23 U ia64

    Struct pst_shminfo contains member
    psh_nattch; /* current # of procs attached (accurate)*/

    Is it possible to know pid's of those processes?

    Sub-question. Is it possible to know if current process is attached
    tho some segment of shared memory?

    Alex Vinokur



  2. Re: To know if a process is attached tho some segment of shared memory

    Alex Vinokur wrote:
    > Struct pst_shminfo contains member
    > psh_nattch; /* current # of procs attached (accurate)*/
    > Is it possible to know PIDs of those processes?


    I don't think so, not from pstat(2).

    > Is it possible to know if current process is attached
    > to some segment of shared memory?


    You can get all memory regions attached to a process. You just need to
    see if in the right address range. But I don't see any addresses in
    "ipcs -m".

  3. Re: To know if a process is attached tho some segment of sharedmemory

    On Sep 24, 8:46*pm, Dennis Handly wrote:
    [snip]
    > You can get all memory regions attached to a process. *


    How?

    It seems, that "ipcs -m" shows all segments of shared memory, not only
    attached to specific process.

    > You just need to
    > see if in the right address range. *But I don't see any addresses in
    > "ipcs -m".


    Ale Vinokur


  4. Re: To know if a process is attached tho some segment of sharedmemory

    Alex Vinokur wrote:
    > On Sep 24, 8:46 pm, Dennis Handly wrote:
    > [snip]
    >> You can get all memory regions attached to a process.

    >
    > How?


    pstat_getprocvm(). (This is the PS_SHARED_MEMORY object type).

    >
    > It seems, that "ipcs -m" shows all segments of shared memory, not only
    > attached to specific process.


    Yes, that's one of the primary uses of it (cleaning up unattached
    segments where the creator never did shmctl(IPC_RMID) would be very
    difficult otherwise).

    >
    >> You just need to
    >> see if in the right address range. But I don't see any addresses in
    >> "ipcs -m".


    Dennis is right here in that you'd need the global virtual address of
    the object to try to correlate the shmid to the per-process object.
    However, he's also right in that nothing reports this. A big part of
    that is that an unattached object doesn't have to have a GVA assigned
    (they do currently in practice, but it isn't really a requirement since
    the shmop(2) documentation is only that once a segment is _attached_ for
    the first time it gets a GVA which is kept). And since MPAS processes
    get a different (private) virtual address anyway, this wouldn't be
    sufficient in practice in any event.

    The closest you could get would be to use to use psh_lpid and psh_segsz
    to check the last pid for a PS_SHARED_MEMORY object of the same size,
    pray that it isn't some other identically sized segment, not the virtual
    address and scan the rest of the processes on the system for the same
    address in use and PS_SHARED_MEMORY. Not anywhere near robust.

    So in summary -- I'm afraid the answer is that there's no way with the
    current pstat interfaces to do this. [As always, using your support
    channels to file an Enhancement Request would be your next option.]

    Don
    --
    kernel, n:
    A part of an operating system that preserves the medieval traditions
    of sorcery and black art.

+ Reply to Thread