delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2009/10/10/04:14:18

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00,SPF_PASS
X-Spam-Check-By: sourceware.org
From: Haojun Bao <baohaojun AT gmail DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: Many Cygwin (mintty) windows - How to close all?
References: <hal2jt$vj3$1 AT ger DOT gmane DOT org> <COL102-W1578D201FE6533BCC5000BB5CC0 AT phx DOT gbl> <2bf229d30910081120q384b329fs7e24b560bf721947 AT mail DOT gmail DOT com> <4ACFE190 DOT 7000700 AT biyani DOT org>
Date: Sat, 10 Oct 2009 16:14:27 +0800
In-Reply-To: <4ACFE190.7000700@biyani.org> (Arun Biyani's message of "Fri, 09 Oct 2009 20:21:20 -0500")
Message-ID: <83ocof1x98.fsf@gmail.com>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (cygwin)
MIME-Version: 1.0
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

Arun Biyani <embedded AT biyani DOT org> writes:

> Chris Sutcliffe wrote:
>>>> Is there some sort of Cygwin command that -
>>>> 1. Closes all Mintty windows
>>>> 2. Unloads services - such as cron
>>>> 3. Exits X server
>>>>
>>>> in short, gets rid of all Cygwin processes so I can update & restart
>>>> without having to do all this myself.
>>>>
>>> I use the attached script (run it elevated on Vista and above) before
>>> updating with setup. This is only tested on Vista.
>>
>> Doing a 'kill -9 -1' works for me in terms of getting rid of all my
>> mintty windows at once.  I'm not sure if it will kill services and
>> exit the X server as well.
>>
>> Chris
>>
> Thanks for the suggestions.
> Arun

Or you may want to check out

http://windows-config.googlecode.com

The following 2 files can do the job you thus wanted:
    http://windows-config.googlecode.com/svn/trunk/bin/windows/terminateModule.py
together with 
    http://windows-config.googlecode.com/svn/trunk/gcode/modules/modules/Program.cs

The C# .net programming provides a `System.Diagnostics' package, which
you can use to enum every process and every PE32 executable (dll or exe)
loaded by each process, then you just grep "cygwin1.dll" and
TerminateProcess each of them. Put it in a python script...

You can terminate all notepad.exe with `terminateModule.py notepad.exe'
for example.

Another thing, when running `terminateModule.py', the python must be the
native win32 python, with pywin32 installed, not the one shipped with
cygwin. The reason should be apparent. Then there comes another problem,
you must run it like
    "c:/python25/python q:/bin/windows/terminateModule.py notepad.exe"
which is too boring

So, I just wrote a bash helper that will make it possible to invoke
native python from the shebang like:

    #!/bin/env pywinstart.exe

the pywinstart.exe is a *general* .exe file, which will only invoke bash
with a `helper.sh' and the command line arguments, in helper.sh, it will
see pywinstart.exe is executing, so instead it will invoke a
*pywinstart.sh*, which then *cygstart* the native python, with the .py
file path "~/bin/windows/terminateModule.py" transformed to it's win32
path using `cygpath -alm'

If you are interested, consider checkout the whole 

http://windows-config.googlecode.com/svn/trunk

and execute its bin/windows/after-check-out.sh and
bin/windows/startup.sh, and reboot. See what happens...

Be fore-warned: it will change your keyboard's CapsLock into Control,
among other not very polite things:-)

>
> --
> Problem reports:       http://cygwin.com/problems.html
> FAQ:                   http://cygwin.com/faq/
> Documentation:         http://cygwin.com/docs.html
> Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019