    }
    return self;
  }
-@@ -202,9 +205,32 @@
+@@ -202,9 +214,32 @@
    [self->adaptors    release];
    [self->requestLock release];
    [self->lock        release];

-    fprintf(stderr, "[%i]: watchdog handling signal %i ..\n",
-            getpid(), _signal);
-    break;
+- (void) receivedEvent: (void*)data
+		  type: (RunLoopEventType)type
+		 extra: (void*)extra
+	       forMode: (NSString*)mode
+{
+  int nextId;
+  WOWatchDogChild *child;
+
+  // NSLog (@"have a child accept the connection");
+  nextId = [readyChildren count] - 1;
+  if (nextId > -1)
+    {
+      child = [readyChildren objectAtIndex: nextId];
+      [readyChildren removeObjectAtIndex: nextId];
+      [child notify];
+    }
+  // else
+  //   NSLog (@"all children busy");
+}
+
+- (void) _cleanupSignalAndEventHandlers
+{
+  int count;
+  NGActiveSocket *controlSocket;
+  NSRunLoop *runLoop;
+
+  [[UnixSignalHandler sharedHandler] removeObserver: self];
+
+  runLoop = [NSRunLoop currentRunLoop];
+  [runLoop removeEvent: (void *) [listeningSocket fileDescriptor]
+                  type: ET_RDESC
+               forMode: NSDefaultRunLoopMode
+                   all: YES];
+
+  for (count = 0; count < numberOfChildren; count++) {
+    controlSocket = [[children objectAtIndex: count] controlSocket];
+    if (controlSocket)
+      [runLoop removeEvent: (void *) [controlSocket fileDescriptor]
+                      type: ET_RDESC
+                   forMode: NSDefaultRunLoopMode
+                       all: YES];
   }
-  fflush(stderr);
-  

 #if defined(__CYGWIN32__) || defined(__MINGW32__)
 
 int WOWatchDogApplicationMain
@@ -39,201 +60,845 @@
 #include <time.h>
 #include <string.h>
 
