6 require Config; import Config;
10 if ($Config{'extensions'} !~ /\bIPC\/SysV\b/) {
11 $reason = 'IPC::SysV was not built';
12 } elsif ($Config{'d_sem'} ne 'define') {
13 $reason = '$Config{d_sem} undefined';
14 } elsif ($Config{'d_msg'} ne 'define') {
15 $reason = '$Config{d_msg} undefined';
18 print "1..0 # Skip: $reason\n";
23 use IPC::SysV qw(IPC_PRIVATE IPC_RMID IPC_NOWAIT IPC_STAT S_IRWXU S_IRWXG S_IRWXO);
26 #Creating a message queue
31 new IPC::Msg(IPC_PRIVATE, S_IRWXU | S_IRWXG | S_IRWXO)
32 || die "msgget: ",$!+0," $!\n";
36 #Putting a message on the queue
39 print $msq->snd($msgtype,$msg,IPC_NOWAIT) ? "ok 2\n" : "not ok 2 # $!\n";
41 #Check if there are messages on the queue
42 $ds = $msq->stat() or print "not ";
45 print "not " unless $ds && $ds->qnum() == 1;
48 #Retreiving a message from the queue
49 $rmsgtype = 0; # Give me any type
50 $rmsgtype = $msq->rcv($rmsg,256,$rmsgtype,IPC_NOWAIT) || print "not ";
53 print "not " unless $rmsgtype == $msgtype && $rmsg eq $msg;
56 $ds = $msq->stat() or print "not ";
59 print "not " unless $ds && $ds->qnum() == 0;
63 (defined $msq && $msq->remove) || print "not ";