@@ -293,38 +293,30 @@ void handle_sigusr1(int sig)
293293/* Quick save and turn off the console */
294294void quick_save_and_poweroff ()
295295{
296- /* Vars */
297- char shell_cmd[2048 ];
298- FILE *fp;
299-
300- /* Send command to kill any previously scheduled shutdown */
301- sprintf (shell_cmd, " pkill %s" , SHELL_CMD_SCHEDULE_POWERDOWN);
302- fp = popen (shell_cmd, " r" );
303- if (fp == NULL ) {
304- printf (" Failed to run command %s\n " , shell_cmd);
296+ printf (" Save Instant Play file\n " );
297+
298+ /* Send command to cancel any previously scheduled powerdown */
299+ if (popen (SHELL_CMD_CANCEL_SCHED_POWERDOWN, " r" ) == NULL )
300+ {
301+ /* Countdown is still ticking, so better do nothing
302+ than start writing and get interrupted!
303+ */
304+ printf (" Failed to cancel scheduled shutdown\n " );
305+ exit (0 );
305306 }
306307
307308 /* Save */
308309 FCEUI_SaveState (quick_save_file);
309310
310- /* Write quick load file */
311- sprintf (shell_cmd, " %s SDL_NOMOUSE=1 \" %s\" --loadStateFile \" %s\" \" %s\" " ,
312- SHELL_CMD_WRITE_QUICK_LOAD_CMD, prog_name, quick_save_file, mRomName );
313- printf (" Cmd write quick load file:\n %s\n " , shell_cmd);
314- fp = popen (shell_cmd, " r" );
315- if (fp == NULL ) {
316- printf (" Failed to run command %s\n " , shell_cmd);
317- }
311+ /* Perform Instant Play save and shutdown */
312+ execlp (SHELL_CMD_INSTANT_PLAY, SHELL_CMD_INSTANT_PLAY,
313+ prog_name, " --loadStateFile" , quick_save_file, mRomName , NULL );
318314
319- /* Clean Poweroff */
320- sprintf (shell_cmd, " %s" , SHELL_CMD_POWERDOWN);
321- fp = popen (shell_cmd, " r" );
322- if (fp == NULL ) {
323- printf (" Failed to run command %s\n " , shell_cmd);
324- }
315+ /* Should not be reached */
316+ printf (" Failed to perform Instant Play save and shutdown\n " );
325317
326318 /* Exit Emulator */
327- CloseGame ( );
319+ exit ( 0 );
328320}
329321
330322static void DoFun (int fskip) {
0 commit comments