#!/usr/bin/perl use strict; use Time::HiRes qw(usleep); my $max = 0; while(my $prog = ) { print STDERR "$prog"; $max++; die "Unable to fork\n" unless(defined(my $pid = fork)); if($pid == 0) # child { die "Unable to exec\n" unless(exec("/usr/bin/ssh localhost /bin/sleep 10")); # die "Unable to exec\n" unless(exec("/bin/sleep 10")); exit(0); } usleep(100000); } for(my $i = 0; $i < $max; $i++) { wait; } print STDERR "\nDONE\n"; #### 001 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345 002 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345 003 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345 004 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345 005 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345 006 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345 007 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345 008 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345 009 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345 010 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345 011 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345 012 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345 013 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345 014 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345 015 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345 016 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345 017 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345 018 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345 019 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345 020 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345 021 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345 022 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345 023 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345 024 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345 025 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345 026 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345 027 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345 028 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345 029 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345 030 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345 031 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345 032 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345 033 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345 034 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345 035 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345 036 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345 037 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345 038 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345 039 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345 040 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345 041 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345 042 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345 043 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345 044 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345 045 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345 046 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345 047 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345 048 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345 049 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345 050 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345 #### … read(0, "002 1234567890123456789012345678"..., 4096) = 4096 write(2, "002 1234567890123456789012345678"..., 100002 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345 ) = 100 lseek(0, 200, SEEK_SET) = 200 lseek(0, 0, SEEK_CUR) = 200 clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x2aaaabb1c1d0) = 2120 nanosleep({0, 100000000}, NULL) = 0 read(0, "", 4096) = 0 wait4(-1, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0, NULL) = 2117 …