On Mon, 22 Sep 2025 12:39:00 GMT, Thomas Stuefe <[email protected]> wrote:

>> The new tests
>> java/lang/ProcessBuilder/FDLeakTest/FDLeakTest.java#fork
>> java/lang/ProcessBuilder/FDLeakTest/FDLeakTest.java#posix_spawn
>> fail on AIX.
>> The tests were added with 
>> [JDK-8210549](https://bugs.openjdk.org/browse/JDK-8210549) .
>> 
>> Error output is
>> java/lang/ProcessBuilder/FDLeakTest/FDLeakTest.java#fork
>> 
>> Opened and leaked ./testfile_FDLeaker.txt (4)
>> ----------System.err:(13/647)----------
>> *** Parent leaked file descriptor 9 ***
>> *** Parent leaked file descriptor 10 ***
>> java.lang.RuntimeException: Failed
>> at FDLeakTest.main(FDLeakTest.java:69)
>> at 
>> java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
>> at java.base/java.lang.reflect.Method.invoke(Method.java:565)
>> at 
>> com.sun.javatest.regtest.agent.MainWrapper$MainTask.run(MainWrapper.java:138)
>> at java.base/java.lang.Thread.run(Thread.java:1474)
>>  
>>  
>> java/lang/ProcessBuilder/FDLeakTest/FDLeakTest.java#posix_spawn
>> 
>> 
>> ----------System.out:(1/46)----------
>> Opened and leaked ./testfile_FDLeaker.txt (4)
>> ----------System.err:(13/647)----------
>> *** Parent leaked file descriptor 9 ***
>> *** Parent leaked file descriptor 10 ***
>> java.lang.RuntimeException: Failed
>> at FDLeakTest.main(FDLeakTest.java:69)
>> at 
>> java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
>> at java.base/java.lang.reflect.Method.invoke(Method.java:565)
>> at 
>> com.sun.javatest.regtest.agent.MainWrapper$MainTask.run(MainWrapper.java:138)
>> at java.base/java.lang.Thread.run(Thread.java:1474)
>
> src/java.base/unix/native/libjava/childproc.c line 101:
> 
>> 99:         (markCloseOnExec(STDERR_FILENO + 1) == -1 && errno != EBADF)) {
>> 100:         return -1;
>> 101:     }
> 
> Most of this explanation pertains to how markDescriptorsCloseOnExec works in 
> general and can either be left out (preferred, since the inner workings are 
> obvious from the context, and if someone does not understand that they should 
> not modify this code) or should at least be moved to a platform-generic place.
> 
> But what is missing is what is actually different on AIX. AFAICS, this code 
> only closes a single file descriptor. How is this going to work? If 10 file 
> descriptors happen to be open, one of which is STDERR_FILENO + 2, the 
> function closes just that one, then returns 0, and all other filedescriptors 
> stay open?

Hi Thomas,
fcntl(4, F_CLOSEM, 0);
closes all open descriptors >=4. Its a special AIX feature linux does not have 
i guess.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/27291#discussion_r2368356693

Reply via email to