Delete all SYSTEM V shared memory and semaphores on UNIX-like systems

前端 未结 11 2482
情话喂你
情话喂你 2020-12-23 14:01

How can I delete all not used semaphores and shared memory with a single command on a UNIX-like system, e.g., Ubuntu?

11条回答
  •  情歌与酒
    2020-12-23 14:56

    Check if there is anything to delete with :

    ipcs -a | grep `whoami`
    

    On linux delete them all via :

    ipcs | nawk -v u=`whoami` '/Shared/,/^$/{ if($6==0&&$3==u) print "ipcrm shm",$2,";"}/Semaphore/,/^$/{ if($3==u) print "ipcrm sem",$2,";"}' | /bin/sh
    

    For sun it would be :

    ipcs -a | nawk -v u=`whoami` '$5==u &&(($1=="m" && $9==0)||($1=="s")){print "ipcrm -"$1,$2,";"}' | /bin/sh
    

    courtsesy of di.uoa.gr

    Check again if all is ok

    For deleting your sems/shared mem - supposing you are a user in a workstation with no admin rights

提交回复
热议问题