forked from Coastal-Imaging-Research-Network/hotm2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshutdown.pl
More file actions
38 lines (25 loc) · 692 Bytes
/
shutdown.pl
File metadata and controls
38 lines (25 loc) · 692 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
37
38
#! /usr/bin/perl
use IPC::SysV qw(IPC_PRIVATE IPC_CREAT S_IRWXU S_IRWXG S_IRWXO);
use IPC::Msg;
$SIG{'ALRM'} = \&goaway;
$| = 1;
$what = "exit";
alarm 15;
$me = $$;
$msgIn = new IPC::Msg( $me, IPC_CREAT|S_IRWXU|S_IRWXG|S_IRWXO);
die "recvmsg create: $!\n" if !defined $msgIn;
foreach $c ( @ARGV ) {
$msgOut = new IPC::Msg( $c, IPC_CREAT|S_IRWXU|S_IRWXG|S_IRWXO);
die "sendmsg create: $!\n" if !defined $msgOut;
$msgOut->snd( 1, pack( "L a*", $me, $what ));
$in = $msgIn->rcv( $buf, 256 );
($code, $resp) = unpack( 'L a*', $buf );
print "cam $c says $resp ($code)\n";
$msgOut->remove;
}
$msgIn->remove;
sub goaway {
print "dies due to signal\n";
$msgIn->remove;
exit;
}