Эх сурвалжийг харах

Avoid using signal() too much, for cohabitation with other commands

HOLZSCHUCH Nicolas 5 жил өмнө
parent
commit
1d90413cd4

+ 17 - 0
lib/Support/ManagedStatic.cpp

@@ -91,4 +91,21 @@ void llvm::llvm_shutdown() {
 
   while (StaticList)
     StaticList->destroy();
+#if TARGET_OS_IPHONE
+  // Reset signal handler(s) (except SIGUSR2, reserved by Python):
+  (void)signal(SIGUSR1, SIG_DFL);
+  (void)signal(SIGHUP, SIG_DFL);
+  (void)signal(SIGINT, SIG_DFL);
+  (void)signal(SIGPIPE, SIG_DFL);
+  (void)signal(SIGTERM, SIG_DFL);
+  (void)signal(SIGILL, SIG_DFL);
+  (void)signal(SIGTRAP, SIG_DFL);
+  (void)signal(SIGABRT, SIG_DFL);
+  (void)signal(SIGFPE, SIG_DFL);
+  (void)signal(SIGBUS, SIG_DFL);
+  (void)signal(SIGSEGV, SIG_DFL);
+  (void)signal(SIGQUIT, SIG_DFL);
+  (void)signal(SIGINFO, SIG_DFL);
+#endif
 }
+

+ 2 - 2
lib/Support/Unix/Path.inc

@@ -177,8 +177,8 @@ std::string getMainExecutable(const char *argv0, void *MainAddr) {
 char exe_path[MAXPATHLEN];
 #if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR
   // On iOS, we can't get the actual executable path (because of ios_system)
-  // We pretend it's in $APPDIR/usr/bin
-  sprintf(exe_path, "%s/usr/bin/%s", ::getenv("APPDIR"), argv0);
+  // We pretend it's in $HOME/Library/usr/bin
+  sprintf(exe_path, "%s/Library/usr/bin/%s", ::getenv("HOME"), argv0);
   return exe_path;
 #endif
   // On OS X the executable path is saved to the stack by dyld. Reading it

+ 10 - 0
lib/Support/Unix/Signals.inc

@@ -77,6 +77,10 @@
 #endif
 #endif
 
+#ifdef __APPLE__
+#include <TargetConditionals.h>
+#endif
+
 using namespace llvm;
 
 static RETSIGTYPE SignalHandler(int Sig);  // defined below.
@@ -212,7 +216,13 @@ static StringRef Argv0;
 /// if there is, it's not our direct responsibility. For whatever reason, our
 /// continued execution is no longer desirable.
 static const int IntSigs[] = {
+#if !TARGET_OS_IPHONE
   SIGHUP, SIGINT, SIGPIPE, SIGTERM, SIGUSR2
+#else 
+	// leave SIGUSR2 alone when running on iPhone (we need it for Python)
+	// This is not perfect, but signals and threads is a difficult combination.
+  SIGHUP, SIGINT, SIGPIPE, SIGTERM
+#endif
 };
 
 /// Signals that represent that we have a bug, and our prompt termination has