sub reapChild { do {} while waitpid(-1,WNOHANG) > 0; } #### use Net::SSH::Expect; ... $SIG{CHLD} = 'DEFAULT'; ... system(...);