#!/usr/bin/perl -w
######################################################################
# (c) Michael Schilli 1999
######################################################################

use Tk;
use Process;

my $topwindow = MainWindow->new();

                        # Button mit langlaufendem Callback
$button = $topwindow->Button(-text => "Press to Start", 
                             -command => \&takes_long);

$labeltext = "READY";

$label = $topwindow->Label("-textvariable", \$labeltext);

$button->pack();
$label->pack();

$proc = Process->new(); # Prozeß-Objekt erzeugen

MainLoop;


# Lang laufende Subroutine
sub takes_long {     
                   # Hintergrundprozeß starten
    $proc->start(sub { sleep 5; });

                   # Rückkehrendes Child abfangen
    $SIG{CHLD} = sub { wait; $labeltext = "READY"; };

                   # Zustand anzeigen
    $labeltext = "BUSY";
}
