Next | System Programming in Perl | 10 |
$| = 1;
while (1) { print "perl% "; my $command = <STDIN>; last if $command eq ''; chomp $command; my ($program, @args) = split /\s+/, $command; my $pid = fork; if (! defined $pid) { print STDERR "Couldn't fork: $!\n" } elsif ($pid != 0) { wait } # The parent else { exec $program, @args; # The child die "Couldn't exec: $!\n"; } }
Next | 10 |