#!/usr/bin/perl use warnings; use strict; use IPC::Open2; my $cmd = '/no/such/command'; my($out,$in); open2($out, $in, $cmd) || die("I thought script should die here: $!"); print $in "the_string\n" || die ("print die here no fork: $!"); open(my $pipe, "$cmd|") || die("But it dies only here: $!");