gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [gnunet] branch master updated: contrib: gnunet_janitor, te


From: gnunet
Subject: [GNUnet-SVN] [gnunet] branch master updated: contrib: gnunet_janitor, terminate: remove win32 functionalities.
Date: Wed, 11 Sep 2019 13:00:12 +0200

This is an automated email from the git hooks/post-receive script.

ng0 pushed a commit to branch master
in repository gnunet.

The following commit(s) were added to refs/heads/master by this push:
     new d5bd0b9e3 contrib: gnunet_janitor, terminate: remove win32 
functionalities.
d5bd0b9e3 is described below

commit d5bd0b9e37d5c5b1bf1c0af6af2dea5ad471b3ce
Author: ng0 <address@hidden>
AuthorDate: Wed Sep 11 10:56:20 2019 +0000

    contrib: gnunet_janitor, terminate: remove win32 functionalities.
    
    This commit is questionable, but since I removed win32 code this
    code no longer has any purpose.
---
 contrib/scripts/gnunet_janitor.py.in | 24 +++++++----------------
 contrib/scripts/terminate.py.in      | 37 ++++--------------------------------
 2 files changed, 11 insertions(+), 50 deletions(-)

diff --git a/contrib/scripts/gnunet_janitor.py.in 
b/contrib/scripts/gnunet_janitor.py.in
index 79e32fb90..b0b50ca76 100644
--- a/contrib/scripts/gnunet_janitor.py.in
+++ b/contrib/scripts/gnunet_janitor.py.in
@@ -11,7 +11,7 @@
 #    WITHOUT ANY WARRANTY; without even the implied warranty of
 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 #    Affero General Public License for more details.
-#   
+#
 #    You should have received a copy of the GNU Affero General Public License
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
@@ -31,24 +31,14 @@ import time
 import signal
 import terminate
 
-if os.name == 'nt':
-    from win32com.client import GetObject
-    WMI = GetObject('winmgmts:')
-
-
 def get_process_list():
     result = []
-    if os.name == 'nt':
-        processes = WMI.InstancesOf('Win32_Process')
-        for p in processes:
-            result.append((p.Properties_('ProcessId').Value, 
re.sub(r'(.+)\.exe', r'\1', p.Properties_('Name').Value)))
-    else:
-        pids = [pid for pid in os.listdir('/proc') if pid.isdigit()]
-        for pid in pids:
-            with open(os.path.join('/proc', pid, 'cmdline'), 'rb') as p:
-                cmdline = p.read().split('\x00')
-                if len(cmdline) > 0:
-                    result.append((pid, cmdline[0]))
+    pids = [pid for pid in os.listdir('/proc') if pid.isdigit()]
+    for pid in pids:
+        with open(os.path.join('/proc', pid, 'cmdline'), 'rb') as p:
+            cmdline = p.read().split('\x00')
+            if len(cmdline) > 0:
+                result.append((pid, cmdline[0]))
     return result
 
 
diff --git a/contrib/scripts/terminate.py.in b/contrib/scripts/terminate.py.in
index 161b4db61..f57ac6167 100644
--- a/contrib/scripts/terminate.py.in
+++ b/contrib/scripts/terminate.py.in
@@ -11,7 +11,7 @@
 #    WITHOUT ANY WARRANTY; without even the implied warranty of
 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 #    Affero General Public License for more details.
-#   
+#
 #    You should have received a copy of the GNU Affero General Public License
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
@@ -24,9 +24,6 @@
 import sys
 import subprocess
 import os
-if os.name == 'nt':
-    import win32api
-    import win32process
 
 
 class dummyobj (object):
@@ -34,35 +31,9 @@ class dummyobj (object):
 
 
 def safe_terminate_process_by_pid(pid, code):
-    if os.name == 'nt':
-        p = dummyobj()
-        p._handle = win32api.OpenProcess(2 | 1024 | 8 | 32 | 16, 0, pid)
-        result = safe_terminate_process(p, code)
-        win32api.CloseHandle(p._handle)
-        return result
-    else:
-        # XXX (F821): Undefined name 'SIGKILL'
-        return os.kill(int(pid), SIGKILL)
+    # XXX (F821): Undefined name 'SIGKILL'
+    return os.kill(int(pid), SIGKILL)
 
 
 def safe_terminate_process(proc, code):
-    if os.name == 'nt':
-        cp = win32api.GetCurrentProcess()
-        result = False
-        dupproc = win32api.DuplicateHandle(cp, proc._handle, cp, 2 | 1024 | 8 
| 32 | 16, 0, 0)
-        try:
-            exitcode = win32process.GetExitCodeProcess(dupproc)
-            if exitcode == 0x103:
-                kernel32 = win32api.GetModuleHandle("kernel32")
-                exitprocess = win32api.GetProcAddress(kernel32, "ExitProcess")
-                th, tid = win32process.CreateRemoteThread(dupproc, None, 0, 
exitprocess, code, 0)
-                win32api.CloseHandle(th)
-                result = True
-            else:
-                result = True
-        # except failed to get exit code? failed to get module handle?
-        finally:
-            win32api.CloseHandle(dupproc)
-        return result
-    else:
-        return proc.kill()
+    return proc.kill()

-- 
To stop receiving notification emails like this one, please contact
address@hidden.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]