diff --git a/src/unix/unixPostProcess.cpp b/src/unix/unixPostProcess.cpp index a3c36f9..d8befd9 100644 --- a/src/unix/unixPostProcess.cpp +++ b/src/unix/unixPostProcess.cpp @@ -81,37 +81,49 @@ bool NetscapeIsRunning(Window *result); bool NetscapeCheckWindow(Window window); #endif // NETSCAPE_SUPPORT +#define MAX_SUBPROCESSES 32 + +static void OnSIGCHLD(int signum); + class UnixPostProcessor : public NormPostProcessor { public: ~UnixPostProcessor(); - bool IsActive() {return (0 != process_id);} + bool IsActive(); bool ProcessFile(const char* path); void Kill(); - void OnSIGCHLD(); + void ClearPid(int pid); private: friend class NormPostProcessor; UnixPostProcessor(); + bool IsActive(unsigned int array_element); + unsigned int GetOpenProcessIdSlot(); + void Kill(unsigned int array_element); - int process_id; + int process_id[MAX_SUBPROCESSES]; #ifdef NETSCAPE_SUPPORT Window window_id; #endif // NETSCAPE_SUPPORT }; // end class UnixPostProcessor +UnixPostProcessor* theprocessor; + UnixPostProcessor::UnixPostProcessor() - : process_id(0) + : process_id() #ifdef NETSCAPE_SUPPORT ,window_id(0) #endif // NETSCAPE_SUPPORT { + signal(SIGCHLD, OnSIGCHLD); } NormPostProcessor* NormPostProcessor::Create() { - return static_cast(new UnixPostProcessor); + //return static_cast(new UnixPostProcessor); + theprocessor = new UnixPostProcessor; + return static_cast(theprocessor); } // end NormPostProcessor::Create() UnixPostProcessor::~UnixPostProcessor() @@ -119,6 +131,31 @@ UnixPostProcessor::~UnixPostProcessor() if (IsActive()) Kill(); } +bool UnixPostProcessor::IsActive() +{ + for (unsigned int i=0;i 0); + //int status; + //while (waitpid(-1, &status, WNOHANG) > 0); signal(SIGCHLD, sigchldHandler); break; } @@ -245,9 +284,17 @@ bool UnixPostProcessor::ProcessFile(const char* path) void UnixPostProcessor::Kill() { - if (!IsActive()) return; + for (unsigned int i=0;iClearPid(p); + } +} #ifdef NETSCAPE_SUPPORT bool CheckForNetscape(const char* cmd)