@@ -125,23 +125,24 @@ static void quit_all(int err) {
125125/* Quick save and turn off the console */
126126static void quick_poweroff ()
127127{
128- /* Vars */
129- char shell_cmd[200 ];
130- FILE *fp;
131-
132- /* Send command to kill any previously scheduled shutdown */
133- sprintf (shell_cmd, " pkill %s" , SHELL_CMD_SCHEDULE_POWERDOWN);
134- fp = popen (shell_cmd, " r" );
135- if (fp == NULL ) {
136- ERROR (" Failed to run command %s\n " , shell_cmd);
128+ /* Send command to cancel any previously scheduled powerdown */
129+ if (popen (SHELL_CMD_CANCEL_SCHED_POWERDOWN, " r" ) == NULL )
130+ {
131+ /* Countdown is still ticking, so better do nothing
132+ than start writing and get interrupted!
133+ */
134+ printf (" Failed to cancel scheduled shutdown\n " );
135+ exit (0 );
137136 }
138137
139- /* Clean Poweroff */
140- sprintf (shell_cmd, " %s" , SHELL_CMD_POWERDOWN);
141- fp = popen (shell_cmd, " r" );
142- if (fp == NULL ) {
143- ERROR (" Failed to run command %s\n " , shell_cmd);
144- }
138+ /* Perform Instant Play save and shutdown */
139+ execlp (SHELL_CMD_POWERDOWN, SHELL_CMD_POWERDOWN);
140+
141+ /* Should not be reached */
142+ printf (" Failed to perform Instant Play save and shutdown\n " );
143+
144+ /* Exit Emulator */
145+ exit (0 );
145146}
146147
147148/* Handler for SIGUSR1, caused by closing the console */
0 commit comments