summaryrefslogtreecommitdiff
path: root/usr/src/lib
diff options
context:
space:
mode:
authorAndy Fiddaman <andy@omniosce.org>2020-08-12 03:33:17 +0100
committerGitHub <noreply@github.com>2020-08-11 22:33:17 -0400
commit1fc24ed72de4ac8eab15db9b0af90b3e9654262b (patch)
treebb25b3653af04a372a1c404619bb53d3deb24bf1 /usr/src/lib
parent6cf46b2989d19f4276d4e941f35d7daff371ad9b (diff)
downloadillumos-joyent-1fc24ed72de4ac8eab15db9b0af90b3e9654262b.tar.gz
OS-8200 LX: serialise parallel vfork()/clone(LX_CLONE_VFORK) invocations (#321)
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com> Reviewed by: Mike Zeller <mike.zeller@joyent.com> Approved by: Jason King <jason.king@joyent.com>
Diffstat (limited to 'usr/src/lib')
-rw-r--r--usr/src/lib/brand/lx/lx_brand/common/signal.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/usr/src/lib/brand/lx/lx_brand/common/signal.c b/usr/src/lib/brand/lx/lx_brand/common/signal.c
index 74abff9c8c..b83a60380d 100644
--- a/usr/src/lib/brand/lx/lx_brand/common/signal.c
+++ b/usr/src/lib/brand/lx/lx_brand/common/signal.c
@@ -26,6 +26,7 @@
/*
* Copyright 2019 Joyent, Inc.
+ * Copyright 2020 OmniOS Community Edition (OmniOSce) Association.
*/
#include <sys/types.h>
@@ -2400,10 +2401,21 @@ lx_signalfd4(int fd, uintptr_t mask, size_t msize, int flags)
return (r == -1 ? -errno : r);
}
+/*
+ * Since this brackets vfork, we also use it as a synchronisation point to
+ * prevent multiple vfork() calls occuring in parallel. This is necessary
+ * because vfork() on illumos is not MT-safe whereas it is on Linux (with
+ * caveats).
+ *
+ * Some real-world applications (java in particular) can run multiple vfork()
+ * calls in parallel across different threads and they need to be serialised
+ * in the lx brand.
+ */
void
lx_block_all_signals()
{
- (void) syscall(SYS_brand, B_BLOCK_ALL_SIGS);
+ while (syscall(SYS_brand, B_BLOCK_ALL_SIGS) != 0 && errno == EAGAIN)
+ yield();
}
void