sub event_loop { my $next_event = &get_next_event; # e.g. time() + 5 if (select($rh, $wh, $eh, $next_event - time())) { &process($rh, $wh, $eh); } elsif ($next_event <= time()) { &do_timed_events; } } &event_loop while $running; #### if (fork()) { $children_spawned++; return 1; } else { # Here, the *very first* child won't have $children_spawned unless ($children_spawned) { print "I'm the first!\n"; &do_main_with_timed_event_processing; } else { &do_main_without_timed_events; } }