JDK-4744948 : (process) Process launched from Runtime.exec() unnecessarily opens font files
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 1.4.0_01
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2002-09-10
  • Updated: 2003-03-14
  • Resolved: 2003-01-13
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 Other Other
1.4.0_04 04Fixed 1.4.1_03Fixed 1.4.2Fixed
Related Reports
Relates :  
Description
We launch a Wscript process (wscript is like sh/ksh/bash shell on windows) from 
Runtime.exec(). This wscript is suppose to call a program (non-gui) which will 
delete some of the jre files and install the new ones. The wscript does wait for 
the JVM process to exit before trying to delete any of its files.

The problem is the child process created from Runtime.exec() opens some font 
files from JRE/lib/fonts (LucidaSansRegular.ttf) for NO reason. The wscript 
spawned doesn't require it or doesn't request it either. Since this font file is 
open and belongs to the jre, the script is unable to delete the file and 
reinstall the new one.

The wscript when run by itself from the command prompt doesn't open any font 
files. Its just when the wscript is launched from Runtime.exec() that the font 
file is opened. 

Attached is a sample testcase to reproduce the problem. It has the following files:

1. Test.class - this brings up a frame with two buttons - "Launch WScript"
and  "Close". When you click on "Launch Wscript", it launches test.js
2. test.js - this sleeps for 10 seconds and then brings up an alert that it
will be closing.
3. Handle.exe, a utility to see the file handles being used by these
executables.

To run the test:

1. Launch Test.class using JRE 1.4.0_01 : "java Test.class"
2. Use handle.exe to see that all the font files are being loaded by
"java.exe"
3. Then click on "Launch Wscript". This will launch test.js
4. Again use handle to see that all the font files are also being loaded by
"wscript.exe"
5. Click "OK" on the alert box of the script.
6. Click "close" to end the test.

You can also just run the wscript interpreter and handle.exe to the that the
font file is not open normally.


Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: 1.4.0_04 1.4.1_03 mantis-beta FIXED IN: 1.4.0_04 1.4.1_03 mantis-beta INTEGRATED IN: 1.4.0_04 1.4.1_03 mantis-b13 mantis-beta
14-06-2004

EVALUATION We don't believe the assertion they are "opened" - we expect they are inherited. The spawning process (Test.java) is a GUI app so has the files open. It sounds to like its a matter of needing to set the FD_CLOEXEC flag to open file descriptors when you exec. The same would be true of any files you don't want to get inherited. Feedback from engineering We don't think this is a bug. Please use above flags and give that a whirl. Will be closing as not a bug as soon as I receive feedback from bug submitter. ###@###.### 2002-09-12 It appears that when we exec a new process on Windows, we pass an argument to Windows to allow open handles to be inherited by the new process. I don't know if any applications count on this behavior. I am going to pass this bug on to the libraries team since they own the code in question. Here is the call to CreateProcess in Win32Process_md.c ret = CreateProcess(0, /* executable name */ cmd, /* command line */ 0, /* process security attribute */ 0, /* thread security attribute */ TRUE, /* inherits system handles */ processFlag, /* selected based on exe type */ envcmd, /* environment block */ cwd, /* change to the new current directory */ &si, /* (in) startup information */ &pi); /* (out) process information */ ###@###.### 2002-09-23 I did a quick search. It appears that we've called CreateProcess with a value of "TRUE" for inheritance of system handles since at least jdk1.1.8. -- iag@sfbay 2002-09-23
23-09-2002