2

I'm seeing strange behavior (file missing, file outdated) in a java program of mine that has to save some information at shutdown (using shutdownhooks), that in turn use the TERM signal.

The obvious workaround is to save as soon as that info is modified, but for performance reasons i'd like to avoid this.

Thing is it seems to me that the tolerance value is set ridiculously short and init (i think that's the name of the watchdog proces) is actually killing the JVM before it can terminate. I don't think that's it's a bug with my app, because i used a testcase where it waited at least 20 seconds but was still terminated almost instantly. You can see this behavior in shutdown and logout, and also in netbeans and it's opened tabs (it won't save them, at least recent 7.1 on java 7).

Is this something i can't avoid and need to work around?

Frédéric Hamidi
  • 258,201
  • 41
  • 486
  • 479
i30817
  • 1,356
  • 2
  • 13
  • 26

1 Answers1

0

The documentation for telinit(8) says that the init process waits 5 seconds between sending the SIGTERM and SIGKILL signals. This delay can be changed through the -t option.

The same -t option is supported by shutdown(8) and relayed to telinit. Therefore, if you want to increase the delay globally on your system, you'll have to edit either your /etc/inittab configuration file or the helper files in /etc/init.d, depending on your distribution.

Frédéric Hamidi
  • 258,201
  • 41
  • 486
  • 479
  • I don't appear to have a inittab (ubuntu 11.10, that i guess uses upstart). And /etc/init.d is a soup of shell scripts. Of those i think the candidates are /etc/init.d/killprocs and /etc/init.d/halt but i can't seem to find a invocation of telinit there. – i30817 Dec 28 '11 at 08:53
  • If your `killprocs` script resembles mine (I'm running gentoo and using openrc on my end), it should invoke `sleep` after both calls to `killall5`, so you can try increasing the duration argument passed to the first `sleep` command. – Frédéric Hamidi Dec 28 '11 at 09:01
  • Well, i found it in /etc/init.d/sendsigs ... but it's definitely not happening. Here is the code http://pastebin.com/W9EX8wkn i even changed the sleep call to 5 (from 1) and it still ended instantly. – i30817 Dec 28 '11 at 10:15