Try to remove the created message queues and semaphores
even in the case of failures.
p4raw-id: //depot/perl@20490
print "1..9\n";
-$msq = new IPC::Msg(IPC_PRIVATE, S_IRWXU | S_IRWXG | S_IRWXO)
- || die "msgget: ",$!+0," $!\n";
+my $msq =
+ new IPC::Msg(IPC_PRIVATE, S_IRWXU | S_IRWXG | S_IRWXO)
+ || die "msgget: ",$!+0," $!\n";
print "ok 1\n";
print "not " unless $ds && $ds->qnum() == 0;
print "ok 8\n";
-$msq->remove || print "not ";
-print "ok 9\n";
+END {
+ (defined $msq && $msq->remove) || print "not ";
+ print "ok 9\n";
+}
print "1..10\n";
-$sem = new IPC::Semaphore(IPC_PRIVATE, 10, S_IRWXU | S_IRWXG | S_IRWXO | IPC_CREAT)
- || die "semget: ",$!+0," $!\n";
+my $sem =
+ new IPC::Semaphore(IPC_PRIVATE, 10, S_IRWXU | S_IRWXG | S_IRWXO | IPC_CREAT)
+ || die "semget: ",$!+0," $!\n";
print "ok 1\n";
print "not " if $sem->getncnt(0);
print "ok 9\n";
-$sem->remove || print "not ";
-print "ok 10\n";
+END {
+ (defined $sem && $sem->remove) || print "not ";
+ print "ok 10\n";
+}