Changeset 9358


Ignore:
Timestamp:
Oct 22, 2009, 2:25:26 AM (13 years ago)
Author:
charles
Message:

(1.7x) backports for 1.76: r9196 #2454: gtk client handles SIGINT (ctrl-c) wrong

Location:
branches/1.7x
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/1.7x/NEWS

    r9357 r9358  
    44  * Use automake's "quieter builds" rule when available
    55==== GTK+ ====
     6  * Fix broken SIGINT (ctrl-c) handling
     7  * Fix tray menu's main window status when Transmission is started minimized
    68  * Fix 1.61 build failure on systems with new versions of glib but older versions of gtk
    7   * Fix tray menu's main window status when Transmission is started minimized
    89
    910=== Transmission 1.75 (2009/09/13) ===
  • branches/1.7x/gtk/main.c

    r9357 r9358  
    260260
    261261static sig_atomic_t global_sigcount = 0;
    262 
    263 static void
    264 fatalsig( int sig )
    265 {
    266     /* revert to default handler after this many */
    267     static const int SIGCOUNT_MAX = 3;
    268 
    269     if( ++global_sigcount >= SIGCOUNT_MAX )
     262static struct cbdata * sighandler_cbdata = NULL;
     263
     264static void
     265signal_handler( int sig )
     266{
     267    if( ++global_sigcount > 1 )
    270268    {
    271269        signal( sig, SIG_DFL );
    272270        raise( sig );
    273271    }
     272    else switch( sig )
     273    {
     274        case SIGINT:
     275            g_message( _( "Got signal %d; trying to shut down cleanly.  Do it again if it gets stuck." ), sig );
     276            doAction( "quit", sighandler_cbdata );
     277            break;
     278    }
    274279}
    275280
     
    277282setupsighandlers( void )
    278283{
    279 #ifdef G_OS_WIN32
    280     const int sigs[] = { SIGINT, SIGTERM };
    281 #else
    282     const int sigs[] = { SIGHUP, SIGINT, SIGQUIT, SIGTERM };
    283 #endif
    284     guint     i;
    285 
    286     for( i = 0; i < G_N_ELEMENTS( sigs ); ++i )
    287         signal( sigs[i], fatalsig );
     284    signal( SIGINT, signal_handler );
    288285}
    289286
     
    435432        struct cbdata * cbdata = g_new0( struct cbdata, 1 );
    436433
     434        sighandler_cbdata = cbdata;
     435
    437436        /* ensure the directories are created */
    438        if(( str = pref_string_get( PREF_KEY_DIR_WATCH )))
    439            gtr_mkdir_with_parents( str, 0777 );
    440        if(( str = pref_string_get( TR_PREFS_KEY_DOWNLOAD_DIR )))
    441            gtr_mkdir_with_parents( str, 0777 );
     437        if(( str = pref_string_get( PREF_KEY_DIR_WATCH )))
     438            gtr_mkdir_with_parents( str, 0777 );
     439        if(( str = pref_string_get( TR_PREFS_KEY_DOWNLOAD_DIR )))
     440            gtr_mkdir_with_parents( str, 0777 );
    442441
    443442        /* initialize the libtransmission session */
Note: See TracChangeset for help on using the changeset viewer.