Commit | Line | Data |
4536f655 |
1 | #!/usr/local/bin/perl -s |
2 | |
3 | use strict ; |
4 | use warnings ; |
5 | our $s ; |
6 | |
3104a1f1 |
7 | print "HELLO DEMO\n" ; |
4536f655 |
8 | |
3104a1f1 |
9 | use File::Basename qw( basename ); |
9a1ca27b |
10 | $ENV{PATH} .= ':' . basename( $0 ) . ':./bin:.'; |
3104a1f1 |
11 | for 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 | |
19 | my @children ; |
20 | |
21 | my $ssfe = $s ? 'ssfe -prompt Stem:' : '' ; |
22 | my $echo = $s ? 'console_echo=1' : '' ; |
23 | |
24 | my $cmd = <<CMD ; |
25 | xterm -T Hello -n Hello -geometry 80x40+0+0 -e $ssfe run_stem $echo hello |
26 | CMD |
27 | |
28 | print "$cmd\n" ; |
29 | |
30 | my @cmd = split ' ', $cmd ; |
31 | s/:/: / for @cmd ; |
32 | |
33 | fork_exec( @cmd ) ; |
34 | |
3104a1f1 |
35 | 1 while wait() != -1; |
36 | |
37 | exit; |
4536f655 |
38 | |
4536f655 |
39 | |
4536f655 |
40 | |
41 | sub cleanup { |
42 | |
43 | print "clean up\n" ; |
44 | |
45 | kill 9, @children ; |
46 | |
47 | wait ; |
48 | exit ; |
49 | |
50 | } |
51 | |
52 | sub 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 | } |