Using ipcrm

This is a discussion on Using ipcrm within the Linux Programming forums, part of the Platform Specific Boards category; Hey I was wondering if there is a way to use ipcrm to remove multiple shared memory segments or semaphores ...

  1. #1
    Registered User
    Join Date
    Oct 2008
    Posts
    9

    Using ipcrm

    Hey

    I was wondering if there is a way to use ipcrm to remove multiple shared memory segments or semaphores from a certain owner.

    Basically, I have a program that if it ends abruptly, I need to be able to clear out the shared memory segments and semaphores that I make, instead of doing it one by one and manually typing in the IDs of these segments, is there a way I can use ipcrm to simply remove everything from a certain owner? Thanks.

  2. #2
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,263
    Quote Originally Posted by eva69 View Post
    Hey

    I was wondering if there is a way to use ipcrm to remove multiple shared memory segments or semaphores from a certain owner.

    Basically, I have a program that if it ends abruptly, I need to be able to clear out the shared memory segments and semaphores that I make, instead of doing it one by one and manually typing in the IDs of these segments, is there a way I can use ipcrm to simply remove everything from a certain owner? Thanks.
    How about:

    Code:
    ipcs | awk '/$USER/ { print $2 }' | xargs ipcrm
    Where $USER is the username in question (WARNING: I believe this should work, but I haven't actually tested it since I don't want to delete any of my SysV resources )
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21