JDK-4805381 : File.deleteOnExit does not work when program is interrupted (^C)
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.io
  • Affected Version: 1.4.2
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2003-01-20
  • Updated: 2003-02-11
  • Resolved: 2003-01-31
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
1.4.2 b16Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Description
Since 1.4.2b05 File.deleteOnExit nolonger works when an app is interupted by 
the user with '<ctrl> C'. The files reigstered as DeleteOnExit are not deleted.

This worked in previous releases and all builds of 1.4.2 before b04.

The testcase attached (TestDeleteOnExit.java) shows the problem.

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: mantis-beta tiger FIXED IN: mantis-beta tiger INTEGRATED IN: mantis-b16 mantis-beta tiger tiger-b05 VERIFIED IN: mantis-beta
14-06-2004

EVALUATION This problem came about as a result of making the logging initialization lazy, 4747357. The current implementation of File.deleteOnExit uses JVM_OnExit which registers the files to be deleted as ExitProc's. These ExitProcs's are not being run in the case where the vm exit's as a result of '<ctrl> C'. However if the shutdown hook for SIGINT is installed JVM_Halt or JVM_Exit get called and the ExitProc's get run. LogManager adds a shutdown hook which eventually adds the default shutdown hooks HUP, INT, TERM. Making the logging initialization lazy means that these default shutdown hooks do not always get added. ###@###.### 2003-01-20 ---------------------------------------- ###@###.### has provided a workaround which is to call Terminator.setup() during System.initializeSystemClass(). Attempts to make this setup lazier cause complications due to the interaction between the package-private Terminator and Shutdown classes, and it doesn't appear that performing this extra initialization affects startup time significantly. Fix is verified and resulting workspace has no new regression test failures. ###@###.### 2003-01-27
27-01-2003