On Thu, 12 Mar 2026 17:59:01 GMT, Roger Riggs <[email protected]> wrote:

> 8379182: [test] java/lang/ProcessBuilder/PipelineLeaksFD.java fails
> Invoking lsof as a child process lead to races between parent and child that 
> affected the open file descriptors.
> 
> Replace use of lsof with native code to test file descriptors that are pipes 
> and show the inode number for debugging. 
> Simple counts of pipe file descriptors are used to look for leaking fds.
> This implementation works on Mac and Linux.
> It may work Musl and Alpine (unconfirmed) and could remove the @requires 
> restriction.

Neat, and a nice reduction in complexity.

I tested on Alpine, the test works. Feel free to remove Alpine from the 
exclusion.

test/jdk/java/lang/ProcessBuilder/libLinuxFDInfo.c line 35:

> 33:         return buf.st_ino;
> 34:     }
> 35: #endif

Just as an idea, if you want to reproduce the nice "xxw" or "xxr" output of 
lsof to distinguish the read- from the write-end of the pipe, you could use 
fcntl and check if the file descriptor is marked as readonly or writeonly. 

E.g. as a second JNI function that takes an fd and returns true for read end, 
false for write end. Or you assemble the string right here and send it back.

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

Marked as reviewed by stuefe (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/30223#pullrequestreview-3973123059
PR Review Comment: https://git.openjdk.org/jdk/pull/30223#discussion_r2958131336

Reply via email to