File: sysinfo-ticker

package info (click to toggle)
ticker 1.13
  • links: PTS
  • area: main
  • in suites: bullseye, sid
  • size: 268 kB
  • sloc: ansic: 259; sh: 152; makefile: 29; perl: 20
file content (37 lines) | stat: -rwxr-xr-x 814 bytes parent folder | download | duplicates (6)
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
#!/usr/bin/perl -w
#
# Scrolls system information.
# A simple example of how to communicate with ticker from a perl program.
# 
# By Joey Hess <joey@kitenet.net>, GPL copyright 1998.

use strict;

my $size=200; # max buffer size.

$SIG{'INT'} = 'quit';
$SIG{'QUIT'} = 'quit';

# Use shared memory to communicate with the ticker program.
my $IPC_PRIVATE = 0;
my $IPC_RMID = 0;
my $key=shmget($IPC_PRIVATE, $size , 0600 ) || die $!;

shmwrite($key, `uptime`, 0 , $size ) || die $!;

# Fork the ticker program off.
if (!fork) {
	exec "ticker","-s$key","-S$size","-c5",@ARGV;
	die "Cannot execute ticker program, is it in the PATH?";
}

while (1) {
	shmwrite($key, `uptime`, 0 , $size ) || die $!;
	sleep 10;
}

sub quit {
	# Mark the shared memory for deletion.
	shmctl($key, $IPC_RMID, 0) || die $!;
        exit;
}