fixed minor bugs in demo scripts and run_stem
[urisagit/Stem.git] / bin / hello_demo
CommitLineData
4536f655 1#!/usr/local/bin/perl -s
2
3use strict ;
4use warnings ;
5our $s ;
6
3104a1f1 7print "HELLO DEMO\n" ;
4536f655 8
3104a1f1 9use File::Basename qw( basename );
10$ENV{PATH} .= ':' . basename( $0 ) . ':.';
11for my $prog qw( run_stem xterm ) {
12 die "Can't find $prog in PATH\n" if
13 system( "which $prog >/dev/null 2>&1" ) != 0;
4536f655 14}
15
4536f655 16
17$SIG{ 'INT' } = \&cleanup ;
18
19my @children ;
20
21my $ssfe = $s ? 'ssfe -prompt Stem:' : '' ;
22my $echo = $s ? 'console_echo=1' : '' ;
23
24my $cmd = <<CMD ;
25xterm -T Hello -n Hello -geometry 80x40+0+0 -e $ssfe run_stem $echo hello
26CMD
27
28print "$cmd\n" ;
29
30my @cmd = split ' ', $cmd ;
31s/:/: / for @cmd ;
32
33fork_exec( @cmd ) ;
34
3104a1f1 351 while wait() != -1;
36
37exit;
4536f655 38
4536f655 39
4536f655 40
41sub cleanup {
42
43 print "clean up\n" ;
44
45 kill 9, @children ;
46
47 wait ;
48 exit ;
49
50}
51
52sub fork_exec {
53
54 my( @exec ) = @_ ;
55
56 if ( my $pid = fork() ) {
57
58 push @children, $pid ;
59 return ;
60 }
61
62 exec @exec ;
63}