forked from Coastal-Imaging-Research-Network/hotm2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsend
More file actions
36 lines (28 loc) · 730 Bytes
/
send
File metadata and controls
36 lines (28 loc) · 730 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#! /usr/bin/perl
use IPC::SysV qw(IPC_PRIVATE IPC_CREAT S_IRWXU S_IRWXG S_IRWXO);
use IPC::Msg;
$which = shift;
$me = $$;
$| = 1;
$SIG{ALRM} = \&goaway;
#print "sending @ARGV\n";
alarm 2; # was 10
$msgOut = new IPC::Msg( $which, S_IRWXU|S_IRWXG|S_IRWXO);
die "sendmsg create: $!\n" if !defined $msgOut;
$msgIn = new IPC::Msg( $me, IPC_CREAT|S_IRWXU|S_IRWXG|S_IRWXO);
die "recvmsg create: $!\n" if !defined $msgIn;
$msgOut->snd( 1, pack( "L a*", $me, "@ARGV" ) );
# here we wait for immediate ok
while(1) {
$in = $msgIn->rcv( $buf, 256 );
($code, $resp) = unpack( "L a*", $buf );
print "$in: $resp\n";
last unless $in == 3;
}
$msgIn->remove;
exit;
sub goaway {
print "dies due to alarm\n";
$msgIn->remove;
exit;
}