psql: Set up cancel handler later
authorPeter Eisentraut <peter_e@gmx.net>
Thu, 3 Oct 2013 01:05:08 +0000 (21:05 -0400)
committerPeter Eisentraut <peter_e@gmx.net>
Thu, 3 Oct 2013 01:05:08 +0000 (21:05 -0400)
The cancel handler was uselessly set up even before the first connection
was opened.  By setting it up afterwards, the user can use Ctrl+C to
abort psql if the initial connection attempt hangs.

Reviewed-by: Dean Rasheed <dean.a.rasheed@gmail.com>
Reviewed-by: Ryan Kelly <rpkelly22@gmail.com>
src/bin/psql/startup.c

index b2264c91fac95611ad1faef7e93fd91f078c2ee2..dc06f6670274c7fb09c0d41ac3dc8ef8528ff469 100644 (file)
@@ -111,8 +111,6 @@ main(int argc, char *argv[])
    setvbuf(stderr, NULL, _IONBF, 0);
 #endif
 
-   setup_cancel_handler();
-
    pset.progname = get_progname(argv[0]);
 
    pset.db = NULL;
@@ -246,6 +244,8 @@ main(int argc, char *argv[])
        exit(EXIT_BADCONN);
    }
 
+   setup_cancel_handler();
+
    PQsetNoticeProcessor(pset.db, NoticeProcessor, NULL);
 
    SyncVariables();