5b525c1783eb34d5752c4016877550affa3da73a
[urisagit/Stem.git] / bin / hello_demo
1 #!/usr/local/bin/perl -s
2
3 use strict ;
4 use warnings ;
5 our $s ;
6
7 if ( -d 'conf' && -e 'bin/run_stem' ) {
8
9         $ENV{PERL5LIB} = 'lib' ;
10         $ENV{PATH} =  "bin:$ENV{PATH}" ;
11 }
12
13 print "HELLO DEMO\n" ;
14
15 $SIG{ 'INT' } = \&cleanup ;
16
17 my @children ;
18
19 my $ssfe = $s ? 'ssfe -prompt Stem:' : '' ;
20 my $echo = $s ? 'console_echo=1' : '' ;
21
22 my $cmd = <<CMD ;
23 xterm -T Hello -n Hello -geometry 80x40+0+0 -e $ssfe run_stem $echo hello
24 CMD
25
26 print "$cmd\n" ;
27
28 my @cmd = split ' ', $cmd ;
29 s/:/: / for @cmd ;
30
31 fork_exec( @cmd ) ;
32
33 while( <STDIN> ) {
34
35         next unless /^q/i ;
36
37         cleanup() ;
38 }
39
40 sub cleanup {
41
42         print "clean up\n" ;
43
44         kill 9, @children ;
45
46         wait ;  
47         exit ;
48
49 }
50
51 sub fork_exec {
52
53         my( @exec ) = @_ ;
54
55         if ( my $pid = fork() ) {
56
57                 push @children, $pid ;
58                 return ;
59         }
60
61         exec @exec ;
62 }