This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Many Cygwin (mintty) windows - How to close all?


Arun Biyani <embedded@biyani.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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]