Legacy quick'n'dirtiness.
[nssm.git] / service.cpp
index 621277d..d7c7e6e 100644 (file)
@@ -907,6 +907,21 @@ int control_service(unsigned long control, int argc, TCHAR **argv) {
     CloseHandle(service_handle);\r
     CloseServiceHandle(services);\r
 \r
+    if (error == ERROR_IO_PENDING) {\r
+      /*\r
+        Older versions of Windows return immediately with ERROR_IO_PENDING\r
+        indicate that the operation is still in progress.  Newer versions\r
+        will return it if there really is a delay.  As far as we're\r
+        concerned the operation is a success.  We don't claim to offer a\r
+        fully-feature service control method; it's just a quick 'n' dirty\r
+        interface.\r
+\r
+        In the future we may identify and handle this situation properly.\r
+      */\r
+      ret = 1;\r
+      error = ERROR_SUCCESS;\r
+    }\r
+\r
     if (ret) {\r
       _tprintf(_T("%s: %s"), canonical_name, error_string(error));\r
       return 0;\r
@@ -949,6 +964,11 @@ int control_service(unsigned long control, int argc, TCHAR **argv) {
     CloseHandle(service_handle);\r
     CloseServiceHandle(services);\r
 \r
+    if (error == ERROR_IO_PENDING) {\r
+      ret = 1;\r
+      error = ERROR_SUCCESS;\r
+    }\r
+\r
     if (ret) {\r
       _tprintf(_T("%s: %s"), canonical_name, error_string(error));\r
       return 0;\r