1
0
Fork 0

Merging upstream version 0.9~rc1.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-24 05:04:40 +01:00
parent 4f4c7c8781
commit 6503461316
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
19 changed files with 126 additions and 131 deletions

View file

@ -119,32 +119,24 @@ bool set_data_feeder( int * const infdp, pid_t * const pidp )
close( fda[0] ) == 0 && close( fda[1] ) == 0 &&
close( fda2[0] ) == 0 && close( fda2[1] ) == 0 )
execlp( file_type.c_str(), file_type.c_str(), "-cdfq", (char *)0 );
if( verbosity >= 0 )
std::fprintf( stderr, "%s: Can't exec `%s': %s.\n",
util_name, file_type.c_str(), std::strerror( errno ) );
show_exec_error( file_type.c_str() );
_exit( 2 );
}
if( pid2 < 0 )
{
if( verbosity >= 0 )
std::fprintf( stderr, "%s: Can't fork `%s': %s.\n",
util_name, file_type.c_str(), std::strerror( errno ) );
_exit( 2 );
}
{ show_fork_error( file_type.c_str() ); _exit( 2 ); }
if( close( fda[0] ) != 0 ||
close( fda2[0] ) != 0 || close( fda2[1] ) != 0 ||
!feed_data( old_infd, fda[1], magic_data, magic_size ) )
_exit( 2 );
if( close( fda[1] ) != 0 )
{ show_error( "Can't close output of decompressor feeder", errno );
_exit( 2 ); }
{ show_close_error( "decompressor feeder" ); _exit( 2 ); }
_exit( wait_for_child( pid2, file_type.c_str() ) );
}
// parent
close( fda[0] ); close( fda[1] ); close( fda2[1] );
if( pid < 0 )
{ show_error( "Can't fork decompressor feeder", errno ); return false; }
{ show_fork_error( "decompressor feeder" ); return false; }
*pidp = pid;
}
else // not compressed
@ -161,14 +153,13 @@ bool set_data_feeder( int * const infdp, pid_t * const pidp )
!feed_data( old_infd, fda[1], magic_data, magic_size ) )
_exit( 2 );
if( close( fda[1] ) != 0 )
{ show_error( "Can't close output of data feeder", errno );
_exit( 2 ); }
{ show_close_error( "data feeder" ); _exit( 2 ); }
_exit( 0 );
}
// parent
close( fda[1] );
if( pid < 0 )
{ show_error( "Can't fork data feeder", errno ); return false; }
{ show_fork_error( "data feeder" ); return false; }
*pidp = pid;
}
return true;
@ -214,6 +205,38 @@ void show_error( const char * const msg, const int errcode,
}
void show_error2( const char * const msg, const char * const name ) throw()
{
if( verbosity >= 0 )
std::fprintf( stderr, "%s: %s `%s': %s.\n",
util_name, msg, name, std::strerror( errno ) );
}
void show_close_error( const char * const prog_name ) throw()
{
if( verbosity >= 0 )
std::fprintf( stderr, "%s: Can't close output of %s: %s.\n",
util_name, prog_name, std::strerror( errno ) );
}
void show_exec_error( const char * const prog_name ) throw()
{
if( verbosity >= 0 )
std::fprintf( stderr, "%s: Can't exec `%s': %s.\n",
util_name, prog_name, std::strerror( errno ) );
}
void show_fork_error( const char * const prog_name ) throw()
{
if( verbosity >= 0 )
std::fprintf( stderr, "%s: Can't fork `%s': %s.\n",
util_name, prog_name, std::strerror( errno ) );
}
void internal_error( const char * const msg )
{
if( verbosity >= 0 )