Activity Stream
93,593 MEMBERS
28 ONLINE
killing a process in python killing a process in python killing a process in python killing a process in python killing a process in python
Results 1 to 2 of 2
  1.    Tweet this post   Share This Post On Facebook Share This Post On Google+
    #1
    Programmar
    Xcode's Avatar

    Python killing a process in python

    Source Code : 
    # linux, mac
    os.kill(pidsignal.SIGKILL)
    killedpidstat os.waitpid(pidos.WNOHANG)
    if 
    killedpid == 0:
    print >> 
    sys.stderr"ACK! PROCESS NOT KILLED?"
     
    # windows variables SYNC by Xcode
    handle subprocess.Popen("someprocess here"shell=False)
    subprocess.Popen("taskkill /F /T /PID %i"%handle.pid shell=True)
     
    #also
    # Create a process that won't end on its own
    import subprocess
    process 
    subprocess.Popen(['python.exe''-c''while 1: pass'])
     
     
    # Kill the process using pywin32
    import win32api
    win32api
    .TerminateProcess(int(process._handle), -1)
     
     
    # Kill the process using ctypes
    import ctypes
    ctypes
    .windll.kernel32.TerminateProcess(int(process._handle), -1)
     
     
    # Kill the proces using pywin32 and pid
    import win32api
    PROCESS_TERMINATE 
    1

    [Login or Register to remove this advertisement]

    handle 
    win32api.OpenProcess(PROCESS_TERMINATEFalseprocess.pid)
    win32api.TerminateProcess(handle, -1)
    win32api.CloseHandle(handle)
     
     
    # Kill the proces using ctypes and pid
    import ctypes
    PROCESS_TERMINATE 
    1
    handle 
    ctypes.windll.kernel32.OpenProcess(PROCESS_TERMINATEFalseprocess.pid)
    ctypes.windll.kernel32.TerminateProcess(handle, -1)
    ctypes.windll.kernel32.CloseHandle(handle
    Xcode Reviewed by Xcode on . killing a process in python # linux, mac os.kill(pid, signal.SIGKILL) killedpid, stat = os.waitpid(pid, os.WNOHANG) if killedpid == 0: print >> sys.stderr, "ACK! PROCESS NOT KILLED?" # windows variables SYNC by Xcode handle = subprocess.Popen("someprocess here", shell=False) subprocess.Popen("taskkill /F /T /PID %i"%handle.pid , shell=True) Rating: 5

  2. The Following 1 Users Say Thank You to Xcode For This Useful Post:
    [ Click to Expand ]

    Bianden19592 (23rd December 2013)

  3.   Advertisements

  4.    Tweet this post   Share This Post On Facebook Share This Post On Google+
    #2
    Thx for this code I really needed.

Thread Information

Users Browsing this Thread

There Are Currently 1 Users Browsing This Thread. (0 Members and 1 Guests)

Similar Threads

  1. [DISCUSSION] Nokia Killing Symbian :'(
    By TyLeR.duRdeN in forum Symbian^3 General Discussions,Request & Help
    Replies: 8
    Last Post: 30th April 2013, 09:01 AM
  2. Get process memory usage
    By Mobile_Guru in forum Delphi
    Replies: 0
    Last Post: 17th April 2012, 12:20 AM
  3. Golden Python 1.00 by mEnPDA -.::Run all python's apps::.-
    By Mobile_Guru in forum Python S60 Zone
    Replies: 1
    Last Post: 18th June 2011, 09:14 PM
  4. Process Monitor Widget Pro v0.9.1.1
    By hoomey in forum Android OS Applications
    Replies: 0
    Last Post: 15th June 2011, 04:03 PM
  5. Replies: 1
    Last Post: 1st March 2011, 06:04 PM

Tags for this Thread

BE SOCIAL
killing a process in python killing a process in python killing a process in python killing a process in python killing a process in python