#/usr/bin/perl -w use strict; my $pid = fork(); die "fork() failed: $!" unless defined $pid; if ($pid) { print "I am the child pid =$pid...\n"; while (1) { `ping 127.0.0.1 -n 5 > nul`; # sleep() won't work on Windows in multiple threads # the pid is a negative number and this a # thread (fork emulation) # there is Windows "weirdness" with sleep # here I started a command that will "wait" # for awhile before returning. # this is inefficent, but appears to work print "I am still the child ". localtime()."\n"; } } else { print "I am the parent\n"; while (sleep(2)) { print "I am still the parent ". localtime(), "\n"; } } __END__ C:\TEMP>perl client_server.pl I am the child pid =-5428... I am the parent I am still the parent Sat Aug 25 20:29:13 2012 I am still the parent Sat Aug 25 20:29:15 2012 I am still the child Sat Aug 25 20:29:16 2012 I am still the parent Sat Aug 25 20:29:17 2012 I am still the parent Sat Aug 25 20:29:19 2012 I am still the child Sat Aug 25 20:29:20 2012 I am still the parent Sat Aug 25 20:29:21 2012 I am still the parent Sat Aug 25 20:29:23 2012 I am still the child Sat Aug 25 20:29:24 2012 I am still the parent Sat Aug 25 20:29:25 2012 I am still the parent Sat Aug 25 20:29:27 2012 I am still the child Sat Aug 25 20:29:28 2012 I am still the parent Sat Aug 25 20:29:29 2012 Terminating on signal SIGINT(2) #I hit CTL-C in the command window... #the parent was running in the foreground...