Skip to content

Commit e9dd250

Browse files
authored
Don't use vfork on android (#118085)
When we start the child process, we clear all signal handlers. This operations ends up clearing the signal handlers also for the parent process. Revert to just using fork for simplicity.
1 parent b6e34b8 commit e9dd250

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/native/libs/System.Native/pal_process.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,11 @@ int32_t SystemNative_ForkAndExecProcess(const char* filename,
314314
sigfillset(&signal_set);
315315
pthread_sigmask(SIG_SETMASK, &signal_set, &old_signal_set);
316316

317-
#if HAVE_VFORK && !(defined(__APPLE__)) // We don't trust vfork on OS X right now.
317+
// vfork on OS X is deprecated
318+
// On Android, signal handlers between parent and child processes are shared with vfork, so when we reset
319+
// the signal handlers during child startup, we end up incorrectly clearing also the ones for the parent.
320+
#if HAVE_VFORK && !defined(__APPLE__) && !defined(TARGET_ANDROID)
321+
318322
// This platform has vfork(). vfork() is either a synonym for fork or provides shared memory
319323
// semantics. For a one gigabyte process, the expected performance gain of using shared memory
320324
// vfork() rather than fork() is 99.5% merely due to avoiding page faults as the kernel does not

0 commit comments

Comments
 (0)