无法创建信号量集:设备Perl上没有剩余空间

时间:2015-03-25 18:06:38

标签: perl parallel-processing ipc shared-memory

我正在尝试在Perl中使用共享内存。它似乎运行良好,但我注意到我在一些程序启动后收到以下错误:

Could not create semaphore set: No space left on device

这是我对共享变量的声明:

my $handle_buffer = tie $buffer, 'IPC::Shareable', undef, { destroy => 1 };
my $clients_shr = tie @clients, 'IPC::Shareable', undef, { destroy => 1 };

我尝试使用以下子例程清除所有变量:

 IPC::Shareable->clean_up_all;
 ..... killing child process

但它不起作用。它似乎挂了,因为之后并非所有进程都被杀死并继续从共享内存中读取并获取:

Use of uninitialized value $shared_variable in string eq at shared.pl line 208, <GEN1> line 14.**

请帮助释放记忆。提前谢谢大家。

编辑

这是一个简单的例子

use IPC::Shareable;
my $buffer;
my $handle_buffer = tie $buffer, 'IPC::Shareable', undef, { destroy => 1 };
$buffer = "Initial value\n";
setpgrp(0,0);
$SIG{INT} = \&kill_all;
sub kill_all() {
     print "Going to kill child processes \n";
     print "Clearing shared memory \n";
     IPC::Shareable->clean_up_all;
     kill -$$;
}
if( fork() == 0 ){
$SIG{INT} = 'DEFAULT';   
    $buffer = "Some value from child";
}
.....
.....
if(fork() == 0) {
$SIG{INT} = 'DEFAULT';   
   if($buffer==$some_value) {

}
}

0 个答案:

没有答案