diff options
Diffstat (limited to '')
-rw-r--r-- | zcmp.cc | 14 |
1 files changed, 10 insertions, 4 deletions
@@ -20,6 +20,7 @@ #include <cctype> #include <cerrno> #include <climits> +#include <csignal> #include <cstdio> #include <cstdlib> #include <cstring> @@ -469,10 +470,15 @@ int main( const int argc, const char * const argv[] ) int retval = cmp( max_size, infd, filenames, print_bytes ); - if( ( ( pid[0] && wait_for_child( pid[0], "data feeder" ) != 0 ) || - ( pid[1] && wait_for_child( pid[1], "data feeder" ) != 0 ) ) && - retval == 0 ) - retval = 2; + if( retval != 0 ) + { + if( pid[0] ) kill( pid[0], SIGTERM ); + if( pid[1] ) kill( pid[1], SIGTERM ); + } + else + if( ( pid[0] && wait_for_child( pid[0], "data feeder" ) != 0 ) || + ( pid[1] && wait_for_child( pid[1], "data feeder" ) != 0 ) ) + retval = 2; for( int i = 0; i < 2; ++i ) { |