From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1277 invoked by alias); 19 Aug 2002 09:16:03 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 1255 invoked by uid 71); 19 Aug 2002 09:16:02 -0000 Date: Mon, 19 Aug 2002 03:26:00 -0000 Message-ID: <20020819091602.1254.qmail@sources.redhat.com> To: nobody@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, From: Andrew Haley Subject: Re: libgcj/7532: shutdown hooks not run upon abnormal termination Reply-To: Andrew Haley X-SW-Source: 2002-08/txt/msg00372.txt.bz2 List-Id: The following reply was made to PR libgcj/7532; it has been noted by GNATS. From: Andrew Haley To: tromey@redhat.com Cc: , gcc-gnats@gcc.gnu.org Subject: Re: libgcj/7532: shutdown hooks not run upon abnormal termination Date: Mon, 19 Aug 2002 10:08:29 +0100 (BST) Tom Tromey writes: > jmr> Shutdown hooks added with Runtime.addShutdownHook() are not run > jmr> if the program terminates abnormally, ie due to Ctrl-C. > > Yeah, definitely a bug. > > jmr> Here's a patch that installs a signal handler to catch SIGHUP, SIGINT, and > jmr> SIGTERM. The handler calls System.exit() so the shutdown hooks run. > jmr> Installation of the signal handlers can be disabled with > jmr> --reduce-signal-usage. > > I don't think we can do this stuff directly from the signal handler. > I'm not sure what a better approach is though. Maybe Andrew has an idea. I think it's legal to do this from a signal handler. However, we might deadlock if a thread is inside a synchronized region at the time the ctrl-C is caught. We could perhaps solve this by sending a message to a dedicated shutdown thread instead of quitting immediately but I don't know if the extra complexity can be justified. However, we must ensure that if a second ctrl-C is received we terminate immediately. > I also don't think we need a gij command-line argument to reduce > signal usage. I agree. Andrew.