1
0
Fork 0

Merging upstream version 1.2~pre2.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-24 05:45:19 +01:00
parent f9513766bb
commit efa0d5eefe
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
22 changed files with 804 additions and 87 deletions

View file

@ -59,7 +59,20 @@ int ztest_stdin( const int infd, int format_index,
{ show_error( "Can't create pipe", errno ); return 1; }
const pid_t pid = fork();
if( pid == 0 ) // child1 (compressor)
if( pid == 0 ) // child1 (compressor feeder)
{
if( close( fda[0] ) != 0 ||
!feed_data( infd, fda[1], magic_data, magic_size ) )
_exit( 1 );
if( close( fda[1] ) != 0 )
{ show_close_error( "data feeder" ); _exit( 1 ); }
_exit( 0 );
}
if( pid < 0 ) // parent
{ show_fork_error( "data feeder" ); return 1; }
const pid_t pid2 = fork();
if( pid2 == 0 ) // child2 (compressor)
{
if( dup2( fda[0], STDIN_FILENO ) >= 0 &&
close( fda[0] ) == 0 && close( fda[1] ) == 0 )
@ -81,25 +94,13 @@ int ztest_stdin( const int infd, int format_index,
show_exec_error( compressor_name );
_exit( 1 );
}
if( pid < 0 ) // parent
if( pid2 < 0 ) // parent
{ show_fork_error( compressor_name ); return 1; }
const pid_t pid2 = fork();
if( pid2 == 0 ) // child2 (compressor feeder)
{
if( close( fda[0] ) != 0 ||
!feed_data( infd, fda[1], magic_data, magic_size ) )
_exit( 1 );
if( close( fda[1] ) != 0 )
{ show_close_error( "data feeder" ); _exit( 1 ); }
_exit( 0 );
}
if( pid2 < 0 ) // parent
{ show_fork_error( "data feeder" ); return 1; }
close( fda[0] ); close( fda[1] );
int retval = wait_for_child( pid, compressor_name, 1 );
if( retval == 0 && wait_for_child( pid2, "data feeder" ) != 0 )
const bool isgzxz = ( format_index == fmt_gz || format_index == fmt_xz );
int retval = wait_for_child( pid2, compressor_name, 1, isgzxz );
if( retval == 0 && wait_for_child( pid, "data feeder" ) != 0 )
retval = 1;
return retval;
}
@ -141,5 +142,6 @@ int ztest_file( const int infd, int format_index,
if( pid < 0 ) // parent
{ show_fork_error( compressor_name ); return 1; }
return wait_for_child( pid, compressor_name, 1 );
const bool isgzxz = ( format_index == fmt_gz || format_index == fmt_xz );
return wait_for_child( pid, compressor_name, 1, isgzxz );
}