 -          
 -          if (isVerbose)
 -            fprintf(stderr, "starting child %i ..\n", getpid());
-+  if (stdout && stderr) {
-+    /* This invocation forces the class initialization of WOCoreApplication,
-+       which causes the NSUserDefaults to be initialized as well with
-+       Defaults.plist. */
-+    [NSClassFromString (appName) port];
- 
+-
 -          pidFile = [pidFile stringByAppendingPathExtension:@"child"];
 -          _writePid(pidFile);
 -          

-                    child, forkCount, status);
-          }
-        }
+    if (childPid) {
+      rc = 0;
+    }
+    else {
+      nsPidFile = [ud objectForKey: @"WOPidFile"];
+      if (!nsPidFile)
+        nsPidFile = [NSString stringWithFormat: @"/var/run/%@/%@.pid",
+                              [processInfo processName],
+                              [processInfo processName]];
+      pidFile = [nsPidFile UTF8String];
+      if (_writePid(nsPidFile)) {
+        respawnDelay = [ud integerForKey: @"WORespawnDelay"];
+        if (!respawnDelay)
+          respawnDelay = 5;
+        /* default is to use the watch dog! */
+        if ([ud objectForKey:@"WOUseWatchDog"] != nil
+            && ![ud boolForKey:@"WOUseWatchDog"])
+          rc = WOApplicationMain(appName, argc, argv);
+        else
+          rc = [[WOWatchDog sharedWatchDog] run: appName argc: argc argv: argv];
       }
+      else {
+        [ud errorWithFormat: @"unable to open pid file: %@", pidFile];
+        rc = -1;
+      }
     }
-    return 0;
   }

===================================================================
--- sope-appserver/NGObjWeb/ChangeLog	(revision 1660)
+++ sope-appserver/NGObjWeb/ChangeLog	(working copy)
@@ -1,3 +1,97 @@
+2009-12-22  Wolfgang Sourdeau  <wsourdeau@inverse.ca>
+
+	* WOWatchDogApplicationMain.m (_listeningAddress): read "WOPort"
+	from the user defaults rather than by invoking [WOApplication
+	port], which returns an NSNumber.
+
+2009-12-14  Wolfgang Sourdeau  <wsourdeau@inverse.ca>
+
+	* WOWatchDogApplicationMain.m (-run:argc:argv:): added a
