my $mw = new MainWindow(); $mw->repeat(30000, \&func); MainLoop(); sub func { my $pid = fork(); if (not defined $pid) { print "resources not available\n"; } elsif ($pid == 1) { # do nothing } elsif ($pid == 0) { # do some calcs (takes a few mins) } }