On Wed, 2012-08-08 at 13:28 +0100, Alan Bateman wrote: > On 07/08/2012 19:07, Neil Richards wrote: > > : > > Digging back into its history, I see that it all stems from running java > > under 'nohup' (e.g. 'nohup java ProgramWithShutdownHooks&'). > > > > 'nohup' prevents things being registered against SIGHUP, so trying to do > > so causes an exception to be thrown. > > > > When this happens, the Terminator code currently decides that it > > shouldn't bother trying to register shutdown hooks for SIGINT or SIGTERM > > either. > > > > The result is that shutdown hooks aren't currently run when a java > > process run using 'nohup' is sent a SIGINT or SIGTERM signal, because of > > the code's (false) assumption that a failure to register a handler for > > SIGHUP must mean that the VM is running in -Xrs mode. > > > > I don't think the current observed behaviour in this scenario is either > > expected or desirable. > > It occurs for both J9 and Hotspot (at least, on my Ubuntu box, bash > > shell). > > > > Hope this helps to clarify the scenario. > > > Thanks for helping to clarify what this issue is about. One thing that > still isn't clear (to me anyway) is whether IAE is really thrown in this > case. I did a quick test on Ubuntu 12.04: > > $ nohup strace -f java Test 2> log & > > and in the log I see the sigactions as I expected: > > [pid 13829] rt_sigaction(SIGHUP, NULL, {SIG_IGN, [], 0}, 8) = 0 > [pid 13829] rt_sigaction(SIGINT, NULL, {SIG_DFL, [], 0}, 8) = 0 > [pid 13829] rt_sigaction(SIGTERM, NULL, {SIG_DFL, [], 0}, 8) = 0 > > So I don't think we are actually getting an IllegalArgumentException in > this case. Maybe you are seeing something different? > > -Alan.
Hi Alan, Apologies, I confused myself about the Hotspot behaviour. (I was testing with 'nohup', but not checking the contents of 'nohup.out' for the output from my registered shutdown hook - doh!). You're correct, when running with Hotspot with 'nohup', no exception is thrown when trying to register a handler for SIGHUP. When running with J9 with 'nohup', the VM notices that a handler registered for SIGHUP is never going to get triggered, so throws the exception to notify the caller (of Signal.handle( )) about this. Regards, Neil -- Unless stated above: IBM email: neil_richards at uk.ibm.com IBM United Kingdom Limited - Registered in England and Wales with number 741598. Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU