# HG changeset patch # User Ryan C. Gordon # Date 1264358718 18000 # Node ID e587ba9d1c8765ccf1f67f9e354d4974c221489e # Parent fa4ea28fd997e68818cef736c2063645b39295b9 Don't force quit in signal handler, since we might double-free things. Instead we set a flag and clean up normally. (transplanted from 7815c90ba55221f47a042339f872207904da0f5c) diff -r fa4ea28fd997 -r e587ba9d1c87 playsound/playsound.c --- a/playsound/playsound.c Sun Jan 24 13:29:27 2010 -0500 +++ b/playsound/playsound.c Sun Jan 24 13:45:18 2010 -0500 @@ -312,22 +312,11 @@ Uint32 ticks = SDL_GetTicks(); assert(signum == SIGINT); + if (done_flag < 0) + return; /* mashing CTRL-C, we get it already. */ - if ((last_sigint != 0) && (ticks - last_sigint < 500)) - { - SDL_PauseAudio(1); - SDL_CloseAudio(); - Sound_Quit(); - SDL_Quit(); - deinit_archive(); - exit(1); - } /* if */ - - else - { - last_sigint = ticks; - done_flag = 1; - } /* else */ + done_flag = ((last_sigint != 0) && (ticks - last_sigint < 500)) ? -1 : 1; + last_sigint = ticks; } /* sigint_catcher */ #endif @@ -1051,12 +1040,15 @@ Sound_FreeSample(sample); close_archive(filename); + + if (done_flag < 0) + break; } /* for */ Sound_Quit(); SDL_Quit(); deinit_archive(); - return(0); + return((done_flag < 0) ? 1 : 0); } /* main */ /* end of playsound.c ... */