Skip to content

Commit 54a86bb

Browse files
bobpengxieDamonFool
bobpengxie
authored andcommitted
8274293: Build failure on macOS with Xcode 13.0 as vfork is deprecated
Backport-of: 252aaa9249d8979366b37d59487b5b039d923e35
1 parent 59ecf3c commit 54a86bb

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/hotspot/os/posix/os_posix.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -1885,7 +1885,11 @@ int os::fork_and_exec(const char* cmd, bool prefer_vfork) {
18851885
// Use always vfork on AIX, since its safe and helps with analyzing OOM situations.
18861886
// Otherwise leave it up to the caller.
18871887
AIX_ONLY(prefer_vfork = true;)
1888+
#ifdef __APPLE__
1889+
pid = ::fork();
1890+
#else
18881891
pid = prefer_vfork ? ::vfork() : ::fork();
1892+
#endif
18891893

18901894
if (pid < 0) {
18911895
// fork failed

src/java.base/unix/native/libjava/ProcessImpl_md.c

+6-2
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,8 @@ static int copystrings(char *buf, int offset, const char * const *arg) {
444444
__attribute_noinline__
445445
#endif
446446

447-
/* vfork(2) is deprecated on Solaris */
447+
/* vfork(2) is deprecated on Darwin */
448+
#ifndef __APPLE__
448449
static pid_t
449450
vforkChild(ChildStuff *c) {
450451
volatile pid_t resultPid;
@@ -463,6 +464,7 @@ vforkChild(ChildStuff *c) {
463464
assert(resultPid != 0); /* childProcess never returns */
464465
return resultPid;
465466
}
467+
#endif
466468

467469
static pid_t
468470
forkChild(ChildStuff *c) {
@@ -573,9 +575,11 @@ spawnChild(JNIEnv *env, jobject process, ChildStuff *c, const char *helperpath)
573575
static pid_t
574576
startChild(JNIEnv *env, jobject process, ChildStuff *c, const char *helperpath) {
575577
switch (c->mode) {
576-
/* vfork(2) is deprecated on Solaris */
578+
/* vfork(2) is deprecated on Darwin*/
579+
#ifndef __APPLE__
577580
case MODE_VFORK:
578581
return vforkChild(c);
582+
#endif
579583
case MODE_FORK:
580584
return forkChild(c);
581585
case MODE_POSIX_SPAWN:

0 commit comments

Comments
 (0)