head	1.2;
access;
symbols
	RELENG_2_2_8_RELEASE:1.1.1.1
	RELENG_2_2_7_RELEASE:1.1.1.1
	RELENG_2_2_6_RELEASE:1.1.1.1
	RELENG_2_2_5_RELEASE:1.1.1.1
	RELENG_2_2_2_RELEASE:1.1.1.1
	RELENG_2_2_1_RELEASE:1.1.1.1
	RELENG_2_2_0_RELEASE:1.1.1.1
	RELENG_2_1_7_RELEASE:1.1.1.1
	RELENG_2_1_6_1_RELEASE:1.1.1.1
	RELENG_2_1_6_RELEASE:1.1.1.1
	RELENG_2_2:1.1.1.1.0.8
	RELENG_2_2_BP:1.1.1.1
	RELENG_2_1_5_RELEASE:1.1.1.1
	RELENG_2_1_0_RELEASE:1.1.1.1
	RELENG_2_1_0:1.1.1.1.0.6
	RELENG_2_1_0_BP:1.1.1.1
	RELENG_2_0_5_RELEASE:1.1.1.1
	RELENG_2_0_5:1.1.1.1.0.4
	RELENG_2_0_5_BP:1.1.1.1
	RELENG_2_0_5_ALPHA:1.1.1.1
	RELEASE_2_0:1.1.1.1
	BETA_2_0:1.1.1.1
	ALPHA_2_0:1.1.1.1.0.2
	perl_4_036_bmake:1.1.1.1
	lwall:1.1.1;
locks; strict;
comment	@# @;


1.2
date	98.09.09.06.49.06;	author markm;	state dead;
branches;
next	1.1;

1.1
date	94.09.10.06.27.48;	author gclarkii;	state Exp;
branches
	1.1.1.1;
next	;

1.1.1.1
date	94.09.10.06.27.49;	author gclarkii;	state Exp;
branches;
next	;


desc
@@


1.2
log
@Old Perl is leaving us. Goodbye, faithful friend.
@
text
@#!/usr/bin/perl
eval 'exec /usr/bin/perl -S $0 ${1+"$@@"}'
	if 0;

require 'sys/ipc.ph';
require 'sys/msg.ph';

$| = 1;

$mode = shift;
die "usage: ipcmsg {r|s}\n" unless $mode =~ /^[rs]$/;
$signal = ($mode eq "s");

$id = semget(0x1234, 1, ($signal ? 0 : &IPC_CREAT) | 0644);
die "Can't get semaphore: $!\n" unless defined($id);
print "semaphore id: $id\n";

if ($signal) {
	while (<STDIN>) {
		print "Signalling\n";
		unless (semop($id, 0, pack("sss", 0, 1, 0))) {
			die "Can't signal semaphore: $!\n";
		}
	}
}
else {
	$SIG{'INT'} = $SIG{'QUIT'} = "leave";
	for (;;) {
		unless (semop($id, 0, pack("sss", 0, -1, 0))) {
			die "Can't wait for semaphore: $!\n";
		}
		print "Unblocked\n";
	}
}

&leave;

sub leave {
	if (!$signal) {
		$x = semctl($id, 0, &IPC_RMID, 0);
		if (!defined($x) || $x < 0) {
			die "Can't remove semaphore: $!\n";
		}
	}
	exit;
}
@


1.1
log
@Initial revision
@
text
@@


1.1.1.1
log
@Initial import of Perl 4.046 bmaked

@
text
@@
