summaryrefslogtreecommitdiffstats
path: root/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'main.c')
-rw-r--r--main.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/main.c b/main.c
index 77cb1f6..167c2b7 100644
--- a/main.c
+++ b/main.c
@@ -82,6 +82,7 @@ enum Mode { m_compress = 0, m_decompress, m_test };
char * output_filename = 0;
int outfd = -1;
+mode_t outfd_mode = S_IRUSR | S_IWUSR;
bool delete_output_on_interrupt = false;
@@ -320,8 +321,7 @@ static bool open_outstream( const bool force )
int flags = O_CREAT | O_WRONLY | o_binary;
if( force ) flags |= O_TRUNC; else flags |= O_EXCL;
- outfd = open( output_filename, flags,
- S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH );
+ outfd = open( output_filename, flags, outfd_mode );
if( outfd < 0 )
{
if( errno == EEXIST ) outfd = -2; else outfd = -1;
@@ -600,6 +600,7 @@ void cleanup_and_fail( const int retval )
{
if( delete_output_on_interrupt )
{
+ delete_output_on_interrupt = false;
if( verbosity >= 0 )
fprintf( stderr, "%s: Deleting output file `%s', if it exists.\n",
program_name, output_filename );
@@ -831,6 +832,7 @@ int main( const int argc, const char * const argv[] )
strlen( default_output_filename ) + 1 );
strcpy( output_filename, default_output_filename );
}
+ outfd_mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
if( !open_outstream( force ) )
{
if( outfd == -1 && retval < 1 ) retval = 1;
@@ -855,6 +857,7 @@ int main( const int argc, const char * const argv[] )
if( program_mode == m_compress )
set_c_outname( input_filename, volume_size != LLONG_MAX );
else set_d_outname( input_filename, eindex );
+ outfd_mode = S_IRUSR | S_IWUSR;
if( !open_outstream( force ) )
{
if( outfd == -1 && retval < 1 ) retval = 1;