Skip

I'm getting error messages when trying to create or clear semaphores in perl on linux.
October 4, 2004 6:24 AM   Subscribe

Perl, semaphores, linux, problems [mi]

When creating a new semaphore I'm getting: No space left on device.

Also, when trying to create/clear an existing new semaphore I get File exists.

Both result in errors.

This leads me to believe that a file somewhere maintains the semaphore count, but for the life of me I can't find where this files exist in any documentation. Any help?
posted by pissfactory to Computers & Internet (5 answers total)
 
ipcs is probabaly what you're looking for- it shows the status of inter-process communication. ipcrm lets you control (e.g. kill) these.
posted by mkultra at 6:35 AM on October 4, 2004


you probably have stuck semaphores lying around.
to get the list of semaphores, ipcs -s. To remove semaphores, to ipcrm sem sem_id for each sem_id you saw in ipcs.

I have this perl script which removes stuck semaphores and shared memory (from bad multiprocess comms.) No guarantees, call it like ./removeIPC.pl username.
#!/usr/bin/perl
$c=0;$d=0;
$username=shift(@ARGV);
$node = `uname -n`;
chomp $node;
@outputsem=`ipcs -s | grep $username | cut -c12-19`;
@outputshm=`ipcs -m | grep $username | cut -c12-19`;
print "Removing semaphores...\n";
foreach (@outputsem) {
        $c++;
        chop;
        `ipcrm sem $_`;
}
print "Removing shared memory...\n";
foreach (@outputshm) {
        $d++;
        chop;
        `ipcrm shm $_`;
}
print "Removed $c semaphores and $d shms from $username on $node\n";

posted by neustile at 6:36 AM on October 4, 2004


Yeah, being out of semaphores gets you an ENOSPC even though it has nothing to do with devices. One of those little oddities, see man semget for more info.

Neustile: A nice illustration of the fact that one of the more than one way to do it's in perl is to not actually use perl at all. *grin*
posted by fvw at 6:54 AM on October 4, 2004


hey, it works!
posted by neustile at 6:56 AM on October 4, 2004


thanks all... perfect advice.
posted by pissfactory at 7:02 AM on October 4, 2004


« Older As I was reflecting on the num...   |  I have a Palm V running OS 3.3... Newer »
This thread is closed to new comments.


Post