2 eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
3 if $running_under_some_shell;
11 die "usage: ipcmsg {r|s}\n" unless $mode =~ /^[rs]$/;
12 $signal = ($mode eq "s");
14 $id = semget(0x1234, 1, ($signal ? 0 : &IPC_CREAT) | 0644);
15 die "Can't get semaphore: $!\n" unless defined($id);
16 print "semaphore id: $id\n";
21 unless (semop($id, pack("sss", 0, 1, 0))) {
22 die "Can't signal semaphore: $!\n";
27 $SIG{'INT'} = $SIG{'QUIT'} = "leave";
29 unless (semop($id, pack("sss", 0, -1, 0))) {
30 die "Can't wait for semaphore: $!\n";
40 $x = semctl($id, 0, &IPC_RMID, 0);
41 if (!defined($x) || $x < 0) {
42 die "Can't remove semaphore: $!\n";