sub launch { my ($pid_file,@process_and_args) = @_; open my $fh, '>', $pid_file # or print to STDOUT for easier handling by ssh? or die "Couldn't create '$pid_file': $!"; print {$fh} $$; exec(@process_and_args) or die "Couldn't launch [@process_and_args]: $!"; };