Commit | Line | Data |
0ade1984 |
1 | use IPC::SysV qw(IPC_PRIVATE IPC_RMID IPC_NOWAIT IPC_STAT S_IRWXU S_IRWXG S_IRWXO); |
2 | |
3 | use IPC::Msg; |
4 | #Creating a message queue |
5 | |
6 | print "1..9\n"; |
7 | |
8 | $msq = new IPC::Msg(IPC_PRIVATE, S_IRWXU | S_IRWXG | S_IRWXO) |
9 | || die "msgget: ",$!+0," $!\n"; |
10 | |
11 | print "ok 1\n"; |
12 | |
13 | #Putting a message on the queue |
14 | $msgtype = 1; |
15 | $msg = "hello"; |
16 | $msq->snd($msgtype,$msg,0) || print "not "; |
17 | print "ok 2\n"; |
18 | |
19 | #Check if there are messages on the queue |
20 | $ds = $msq->stat() or print "not "; |
21 | print "ok 3\n"; |
22 | |
23 | print "not " unless $ds && $ds->qnum() == 1; |
24 | print "ok 4\n"; |
25 | |
26 | #Retreiving a message from the queue |
27 | $rmsgtype = 0; # Give me any type |
28 | $rmsgtype = $msq->rcv($rmsg,256,$rmsgtype,IPC_NOWAIT) || print "not "; |
29 | print "ok 5\n"; |
30 | |
31 | print "not " unless $rmsgtype == $msgtype && $rmsg eq $msg; |
32 | print "ok 6\n"; |
33 | |
34 | $ds = $msq->stat() or print "not "; |
35 | print "ok 7\n"; |
36 | |
37 | print "not " unless $ds && $ds->qnum() == 0; |
38 | print "ok 8\n"; |
39 | |
40 | $msq->remove || print "not "; |
41 | print "ok 9\n"; |