Replacing syscall(_NR_fork) on linux with syscall(_NR_clone) (original) (raw)

David Holmes david.holmes at oracle.com
Fri Apr 10 07:47:14 UTC 2015


In os::fork_and_exec we provide a per platform fork/exec implementation for use by the OnError and OnOutOfMemory JVM options.

On linux this is implemented with direct syscalls to _NR_fork (sys_fork) and _NR_execve.

We already encountered a problem on linux-sparc:

http://mail.openjdk.java.net/pipermail/hotspot-runtime-dev/2015-February/013811.html

due to a different register usage for the return value, which is so far restricted to the 7u train but will need addressing in 8u and 9.

Further it seems that the fork syscall has actually been deprecated for quite some time and we are now seeing kernels on some platforms which are no longer providing any of the deprecated syscalls - we simply get an error ENOSYS.

The fork() library was updated to use clone a long time ago, but as I understand it we can't use the fork() library call because we might be executing in a signal-handling context within the error handler.

So I'm considering switching to use the clone syscall for all linux systems.

Thoughts/comments?

David



More information about the hotspot-dev mailing list