瀏覽代碼

sigaction

David Rose 16 年之前
父節點
當前提交
25117835e0

+ 14 - 0
direct/src/plugin/p3dInstanceManager.cxx

@@ -66,6 +66,15 @@ P3DInstanceManager() {
   icc.dwICC = ICC_PROGRESS_CLASS;
   InitCommonControlsEx(&icc);
 #endif
+
+#ifndef _WIN32
+  // On Mac or Linux, we'd better ignore SIGPIPE, or this signal will
+  // shut down the browser if the plugin exits unexpectedly.
+  struct sigaction ignore;
+  memset(&ignore, 0, sizeof(ignore));
+  ignore.sa_handler = SIG_IGN;
+  sigaction(SIGPIPE, &ignore, &_old_sigpipe);
+#endif  // _WIN32
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -84,6 +93,11 @@ P3DInstanceManager::
     _started_notify_thread = false;
   }
 
+#ifndef _WIN32
+  // Restore the original SIGPIPE handler.
+  sigaction(SIGPIPE, &_old_sigpipe, NULL);
+#endif  // _WIN32
+
   if (_xcontents != NULL) {
     delete _xcontents;
   }

+ 8 - 0
direct/src/plugin/p3dInstanceManager.h

@@ -22,6 +22,10 @@
 #include <map>
 #include <vector>
 
+#ifndef _WIN32
+#include <signal.h>
+#endif
+
 class P3DInstance;
 class P3DSession;
 class P3DPackage;
@@ -135,6 +139,10 @@ private:
   NotifyInstances _notify_instances;
   P3DConditionVar _notify_ready;
 
+#ifndef _WIN32
+  struct sigaction _old_sigpipe;
+#endif
+
   static P3DInstanceManager *_global_ptr;
 };
 

+ 0 - 10
direct/src/plugin_npapi/startup.cxx

@@ -21,10 +21,6 @@
 #include <malloc.h>
 #endif
 
-#ifdef __APPLE__
-#include <signal.h>
-#endif
-
 static ofstream logfile;
 ostream *nout_stream = &logfile;
 
@@ -134,12 +130,6 @@ NP_Initialize(NPNetscapeFuncs *browserFuncs,
   }
 #endif
 
-#ifdef __APPLE__
-  // On Mac, we'd better ignore SIGPIPE, or this signal will shut down
-  // the application if the plugin exits unexpectedly.
-  signal(SIGPIPE, SIG_IGN);
-#endif  // __APPLE__
-
   return NPERR_NO_ERROR;
 }
 

+ 3 - 2
direct/src/showutil/Packager.py

@@ -1929,8 +1929,9 @@ class Packager:
         if filename:
             newFilename = Filename('/'.join(moduleName.split('.')))
             newFilename.setExtension(filename.getExtension())
-            package.addFile(filename, newName = newFilename.cStr(),
-                            deleteTemp = True, explicit = True, extract = True)
+            self.currentPackage.addFile(
+                filename, newName = newFilename.cStr(),
+                deleteTemp = True, explicit = True, extract = True)
 
         self.currentPackage.mainModule = (moduleName, newName)