Author: rfm
Date: Thu Oct 15 12:19:19 2015
New Revision: 39069

URL: http://svn.gna.org/viewcvs/gnustep?rev=39069&view=rev
Log:
Add shutodwn function

Modified:
    libs/ec/trunk/ChangeLog
    libs/ec/trunk/EcTest.h
    libs/ec/trunk/EcTest.m

Modified: libs/ec/trunk/ChangeLog
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/ec/trunk/ChangeLog?rev=39069&r1=39068&r2=39069&view=diff
==============================================================================
--- libs/ec/trunk/ChangeLog     (original)
+++ libs/ec/trunk/ChangeLog     Thu Oct 15 12:19:19 2015
@@ -1,3 +1,9 @@
+2015-10-15  Richard Frith-Macdonald <[email protected]>
+
+       * EcTest.h:
+       * EcTest.m:
+       Add new function to shut down a process via DO connection.
+
 2015-10-14  Richard Frith-Macdonald <[email protected]>
 
        * EcUserDefaults.h:

Modified: libs/ec/trunk/EcTest.h
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/ec/trunk/EcTest.h?rev=39069&r1=39068&r2=39069&view=diff
==============================================================================
--- libs/ec/trunk/EcTest.h      (original)
+++ libs/ec/trunk/EcTest.h      Thu Oct 15 12:19:19 2015
@@ -58,6 +58,7 @@
  */
 - (void) ecTestSetConfig: (in bycopy NSData*)data
                   forKey: (in bycopy NSString*)key;
+
 @end
 
 /** This function obtains a Distributed Objects proxy to the EcProcess
@@ -89,3 +90,10 @@
 extern void
 EcTestSetConfig(id<EcTest> process, NSString *key, id value);
 
+/** This function shuts down the remote process, gracefully if possible,
+ * but then with a kill if graceful shutdown fails.<br />
+ * Returns YES on graceful shutdown, NO on timeout.
+ */
+extern BOOL
+EcTestShutdown(id<EcTest> process, NSTimeInterval timeout);
+

Modified: libs/ec/trunk/EcTest.m
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/ec/trunk/EcTest.m?rev=39069&r1=39068&r2=39069&view=diff
==============================================================================
--- libs/ec/trunk/EcTest.m      (original)
+++ libs/ec/trunk/EcTest.m      Thu Oct 15 12:19:19 2015
@@ -177,3 +177,41 @@
 
 }
 
+BOOL
+EcTestShutdown(id<EcTest> process, NSTimeInterval timeout)
+{
+  int           pid;
+  NSConnection  *conn;
+  NSDate        *when;
+
+  conn = [(NSDistantObject*)process connectionForProxy];
+  pid = [(id<CmdClient>)process processIdentifier];
+  [(id<CmdClient>)process cmdQuit: 0];
+  if (timeout > 0)
+    {
+      when = [NSDate dateWithTimeIntervalSinceNow: timeout];
+    }
+  else
+    {
+      when = [NSDate distantFuture];
+    }
+
+  while ([conn isValid] && [when timeIntervalSinceNow] > 0.0)
+    {
+      NS_DURING
+        [(id<CmdClient>)process processIdentifier];
+      NS_HANDLER
+      NS_ENDHANDLER
+      [NSThread sleepForTimeInterval: 0.1];
+    }
+  if ([conn isValid])
+    {
+      kill(pid, 9);
+      [[conn sendPort] invalidate];
+      [conn invalidate];
+      return NO;
+    }
+  return YES;
+}
+
+


_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs

Reply via email to