File: clean_shm.pl

package info (click to toggle)
libhtml-template-perl 2.97-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 740 kB
  • sloc: perl: 2,572; makefile: 8
file content (20 lines) | stat: -rwxr-xr-x 516 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/env perl
use strict;
use warnings;

# this script deletes all shared memory segments accessible by the
# running user.  Probably only works on Linux systems.

open(IPCS, 'ipcs |') or die "Probs opening icps : $!";

my $mode = 0;
while (<IPCS>) {
    if (/(Shared)|(Semaphore)|(Message)/) {
        $mode++;
        next;
    }
    next unless /^0x[0-9a-f]+\s(\d+)\s.*$/;
    system("ipcrm shm $1") if ($mode == 1);
    system("ipcrm sem $1") if ($mode == 2);
    system("ipcrm msg $1") if ($mode == 3);
}