Thread: Using ipcrm

  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
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    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