Skip to content

Commit 252aaa9

Browse files
bobpengxieDamonFool
bobpengxie
authored andcommitted
8274293: Build failure on macOS with Xcode 13.0 as vfork is deprecated
Reviewed-by: alanb, stuefe, rriggs
1 parent 7700b25 commit 252aaa9

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
@@ -1946,7 +1946,11 @@ int os::fork_and_exec(const char* cmd, bool prefer_vfork) {
19461946
// Use always vfork on AIX, since its safe and helps with analyzing OOM situations.
19471947
// Otherwise leave it up to the caller.
19481948
AIX_ONLY(prefer_vfork = true;)
1949+
#ifdef __APPLE__
1950+
pid = ::fork();
1951+
#else
19491952
pid = prefer_vfork ? ::vfork() : ::fork();
1953+
#endif
19501954

19511955
if (pid < 0) {
19521956
// 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)