Skip to content

Commit

Permalink
Fix nwipe not auto exiting on completion in non gui mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
PartialVolume committed Nov 27, 2023
1 parent f61b593 commit 626ca38
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 28 deletions.
62 changes: 36 additions & 26 deletions src/nwipe.c
Original file line number Diff line number Diff line change
Expand Up @@ -737,32 +737,6 @@ int main( int argc, char** argv )
}
}

/* Kill the temperature update thread */
if( nwipe_temperature_thread )
{
if( nwipe_options.verbose )
{
nwipe_log( NWIPE_LOG_INFO, "Cancelling the temperature thread." );
}

/* We don't want to use pthread_cancel as our temperature thread is aware of the control-c
* signal and will exit itself we just join the temperature thread and wait for confirmation
*/
r = pthread_join( nwipe_temperature_thread, NULL );
if( r != 0 )
{
nwipe_log( NWIPE_LOG_WARNING,
"main()>pthread_join():Error when waiting for temperature thread to cancel." );
}
else
{
if( nwipe_options.verbose )
{
nwipe_log( NWIPE_LOG_INFO, "temperature thread has been cancelled" );
}
}
}

/* Release the gui. */
if( !nwipe_options.nogui )
{
Expand Down Expand Up @@ -839,6 +813,42 @@ int main( int argc, char** argv )
thread_timeout_counter--;
sleep( 1 );
}

/* Now all the wipe threads have finished, we can issue a terminate_signal = 1
* which will cause the temperature update thread to terminate, this is necessary
* because in gui mode the terminate_signal is set when the user presses a key to
* exit on completion of all the wipes, however in non gui mode that code isn't
* active (being in the gui section) so here we need to set the terminate signal
* specifically for a completed wipes/s just for non gui mode.
*/
terminate_signal = 1;

/* Kill the temperature update thread */
if( nwipe_temperature_thread )
{
if( nwipe_options.verbose )
{
nwipe_log( NWIPE_LOG_INFO, "Cancelling the temperature thread." );
}

/* We don't want to use pthread_cancel as our temperature thread is aware of the control-c
* signal and will exit itself we just join the temperature thread and wait for confirmation
*/
r = pthread_join( nwipe_temperature_thread, NULL );
if( r != 0 )
{
nwipe_log( NWIPE_LOG_WARNING,
"main()>pthread_join():Error when waiting for temperature thread to cancel." );
}
else
{
if( nwipe_options.verbose )
{
nwipe_log( NWIPE_LOG_INFO, "temperature thread has been cancelled" );
}
}
}

if( nwipe_options.verbose )
{
for( i = 0; i < nwipe_selected; i++ )
Expand Down
4 changes: 2 additions & 2 deletions src/version.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* used by configure to dynamically assign those values
* to documentation files.
*/
const char* version_string = "0.35.2";
const char* version_string = "0.35.3";
const char* program_name = "nwipe";
const char* author_name = "Martijn van Brummelen";
const char* email_address = "[email protected]";
Expand All @@ -14,4 +14,4 @@ Modifications to original dwipe Copyright Andy Beverley <[email protected]>\n\
This is free software; see the source for copying conditions.\n\
There is NO warranty; not even for MERCHANTABILITY or FITNESS\n\
FOR A PARTICULAR PURPOSE.\n";
const char* banner = "nwipe 0.35.2";
const char* banner = "nwipe 0.35.3";

0 comments on commit 626ca38

Please sign in to comment.