Fix nwipe not auto exiting on completion in non gui mode.

This commit is contained in:
PartialVolume
2023-11-27 23:39:50 +00:00
parent f61b593093
commit 626ca3826c
2 changed files with 38 additions and 28 deletions

View File

@@ -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. */ /* Release the gui. */
if( !nwipe_options.nogui ) if( !nwipe_options.nogui )
{ {
@@ -839,6 +813,42 @@ int main( int argc, char** argv )
thread_timeout_counter--; thread_timeout_counter--;
sleep( 1 ); 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 ) if( nwipe_options.verbose )
{ {
for( i = 0; i < nwipe_selected; i++ ) for( i = 0; i < nwipe_selected; i++ )

View File

@@ -4,7 +4,7 @@
* used by configure to dynamically assign those values * used by configure to dynamically assign those values
* to documentation files. * to documentation files.
*/ */
const char* version_string = "0.35.2"; const char* version_string = "0.35.3";
const char* program_name = "nwipe"; const char* program_name = "nwipe";
const char* author_name = "Martijn van Brummelen"; const char* author_name = "Martijn van Brummelen";
const char* email_address = "git@brumit.nl"; const char* email_address = "git@brumit.nl";
@@ -14,4 +14,4 @@ Modifications to original dwipe Copyright Andy Beverley <andy@andybev.com>\n\
This is free software; see the source for copying conditions.\n\ This is free software; see the source for copying conditions.\n\
There is NO warranty; not even for MERCHANTABILITY or FITNESS\n\ There is NO warranty; not even for MERCHANTABILITY or FITNESS\n\
FOR A PARTICULAR PURPOSE.\n"; FOR A PARTICULAR PURPOSE.\n";
const char* banner = "nwipe 0.35.2"; const char* banner = "nwipe 0.35.3";