kill a process in XP

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tor Erik Sønvisen

    #1

    kill a process in XP

    Hi.

    From my Python-program I spawn a new process. When using P_NOWAIT spawnl
    returns the pid but in windows it returns a process handle.
    Later I want to kill this process. How can I do this when I only have the
    process handle?

    -tores-


  • Dave Brueck

    #2
    Re: kill a process in XP

    Tor Erik Sønvisen wrote:[color=blue][color=green]
    >>From my Python-program I spawn a new process. When using P_NOWAIT spawnl[/color]
    > returns the pid but in windows it returns a process handle.
    > Later I want to kill this process. How can I do this when I only have the
    > process handle?[/color]

    Try ctypes - if it's really a Windows handle, then this should work:

    from ctypes import *
    windll.kernel32 .TerminateProce ss(h, 0) # or whatever return code you want

    -Dave

    Comment

    • Cameron Laird

      #3
      Re: kill a process in XP

      In article <mailman.2971.1 109178189.22381 .python-list@python.org >,
      Dave Brueck <dave@pythonapo crypha.com> wrote:[color=blue]
      >Tor Erik Sønvisen wrote:[color=green][color=darkred]
      >>>From my Python-program I spawn a new process. When using P_NOWAIT spawnl[/color]
      >> returns the pid but in windows it returns a process handle.
      >> Later I want to kill this process. How can I do this when I only have the
      >> process handle?[/color]
      >
      >Try ctypes - if it's really a Windows handle, then this should work:
      >
      >from ctypes import *
      >windll.kernel3 2.TerminateProc ess(h, 0) # or whatever return code you want
      >
      >-Dave[/color]

      I sometimes am so irritated with attendant portability issues
      that I open a channel between parent and child, which I use to
      send an exit-now message.

      Comment

      Working...