Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Dennis Lee Bieber Newsgroups: comp.lang.python Subject: Re: (Execution) Termination bit, Alternation bit. Date: Sun, 20 Dec 2015 11:21:11 -0500 Organization: IISS Elusive Unicorn Lines: 43 Message-ID: References: <9Bldy.3723$Bz5.1578@fx04.iad> <864af$56760c5f$d47876e2$48630@news.ziggo.nl> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de TbjOrPwr5Mh1t5k6+V9yGQG+WtZ6o3qz84eUWcQJwpdg== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'warnings': 0.03; 'apis': 0.07; 'url:msdn': 0.07; 'message-id:@4ax.com': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'terminates': 0.09; 'caveats': 0.16; 'descriptors,': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'subject:bit': 0.16; 'threads': 0.16; 'url:85)': 0.16; 'memory': 0.17; 'mechanism': 0.18; 'url:home': 0.18; 'windows': 0.20; '2015': 0.20; 'preferred': 0.20; 'terminate': 0.22; 'dec': 0.23; 'example': 0.26; 'developers': 0.26; 'header:X-Complaints-To:1': 0.26; 'wonder': 0.27; 'this.': 0.28; 'table': 0.32; 'subject:) ': 0.32; 'usually': 0.33; 'open': 0.33; 'file': 0.34; 'gives': 0.35; 'done': 0.35; 'skip:> 10': 0.35; 'but': 0.36; 'there': 0.36; 'possible': 0.36; 'cases': 0.36; 'url:library': 0.36; 'to:addr :python-list': 0.36; 'method': 0.37; 'received:org': 0.37; 'charset:us-ascii': 0.37; 'itself': 0.38; 'data': 0.39; 'does': 0.39; 'application': 0.39; 'system.': 0.39; 'along': 0.39; 'skip:e 20': 0.39; 'to:addr:python.org': 0.40; 'called': 0.40; 'some': 0.40; 'share': 0.61; "you'll": 0.61; 'further': 0.62; 'course': 0.62; 'more': 0.63; 'information': 0.63; 'url:%28': 0.66; 'url:%29': 0.66; 'url:%1': 0.67; 'url:en-us': 0.72; 'killing': 0.84; 'dennis': 0.91; 'instantly': 0.93 X-Injected-Via-Gmane: http://gmane.org/ X-Gmane-NNTP-Posting-Host: adsl-108-79-218-140.dsl.klmzmi.sbcglobal.net X-Newsreader: Forte Agent 6.00/32.1186 X-No-Archive: YES X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:100630 On Sun, 20 Dec 2015 12:25:30 +0100, "Skybuck Flying" declaimed the following: > >This does make me wonder how Windows 7 terminates threads/processes/hanging >applications. > >Apperently there is some kind of mechanism for this. > And if you've done it you'll have seen warnings about possible data corruption or further misbehavior of the system. >Perhaps it's not fully exposed to application developers or perhaps in a >somewhat more complex way via all kinds of APIs ? > Of course it is exposed... It's even called TerminateProcess https://msdn.microsoft.com/en-us/library/windows/desktop/ms686714%28v=vs.85%29.aspx >An example of how to terminate threads/processes instantly on Windows 7 >could be interesting. There is also TerminateThread https://msdn.microsoft.com/en-us/library/windows/desktop/ms686717%28v=vs.85%29.aspx but note all the caveats about its use. Along with those of TerminateProcess. In both cases the preferred method is for the process/thread ITSELF to call Exit(Process|Thread) in response to some other signal that it reads. Killing a process is usually "safe" -- the OS process information table gives it access to the open file descriptors, memory allocation, etc. so the OS can force close/release of resources. Killing threads is NOT "safe" -- since they share memory/resources with the other threads in the process. -- Wulfraed Dennis Lee Bieber AF6VN wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/