Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In case processes are still running when trying to close a session, say which ones #448

Closed
GoogleCodeExporter opened this issue Jun 4, 2015 · 12 comments

Comments

@GoogleCodeExporter
Copy link

Clicking on the "X" in the window's title bar may result in:

---------------------------
mintty
---------------------------
Processes are running in session.
Close anyway?
---------------------------
OK   Cancel   
---------------------------

It would be nice to actually list as part of the message which processes these 
are.

Original issue reported on code.google.com by sschuberth on 14 Apr 2015 at 7:33

@GoogleCodeExporter
Copy link
Author

Hmm, basically the shell, and everything started from it, which you are likely 
to see in the window. Isn't that sufficient? Other terminals don't provide such 
a list either, most don't even ask.

Original comment by towom...@googlemail.com on 6 May 2015 at 8:36

@GoogleCodeExporter
Copy link
Author

In my case I did not see in the window which processes were running. I'm not 
sure how I managed to do that, probably I had accidentally put a process in the 
background. But as mintty already knows there are processes still running I 
thought it should be easy to get their names (or at least pids).

Original comment by sschuberth on 6 May 2015 at 8:46

@mintty
Copy link
Owner

mintty commented Jul 14, 2015

Please try the child process display feature (use the "Download ZIP" button for a test version).

@sschuberth
Copy link

I've tried it, but it does not seem to work correctly. I've replaced the mintty.exe from Git for Windows 2.x with one built from master, started Git Bash, launched gitk &, and then clicked on the window's close button. The prompt I was getting just shows an empty list:

---------------------------
mintty
---------------------------
Processes are running in session:
Close anyway?
---------------------------
OK   Cancel   
---------------------------

@mintty
Copy link
Owner

mintty commented Jul 14, 2015

I forgot to point out that this feature requires procps to be installed. I don't know what specific adapted cygwin environment Git for Windows brings along but that's probably the missing issue.
Maybe I'll change the solution to use ps rather than procps.

@sschuberth
Copy link

Git for Windows 2.x is based on MSYS2, not on Cygwin directly. However, luckily MSYS2 has a package for procps, so I'll give it a try again with having that installed.

@sschuberth
Copy link

So I've installed procps from the MSYS2 repository to my Git for Windows 2.x directory and it basically seems to be working now. I get

---------------------------
mintty
---------------------------
Processes are running in session:
  PID TTY          TIME CMD
 1376 pty0     00:00:00 bash
10756 pty0     00:00:02 wish
Close anyway?
---------------------------
OK   Cancel   
---------------------------

The only odd thing is that the reported PIDs do not match the ones reported by Windows task manager for these processes. Compared to the output of ps, it seems that procps only reports the PID, but not the WINPID. Moreover, there seems to be no way for procps to (also) output the WINPID. As IMO the WINPID would make more sense here, maybe indeed use ps instead of procps?

@mintty
Copy link
Owner

mintty commented Jul 16, 2015

Unfortunately, cygwin ps is a limited implementation of ps and not very configurable. There is only one output format including the WINPID which clutters the output with useless overhead and also it's too long for the message box so already the header line wraps, like this:

---------------------------
Processes are running in session:
      PID    PPID    PGID     WINPID   TTY     UID    STIME 
COMMAND
     9076    5596    9076       7680  pty3    133715 13:41:37 
/usr/bin/bash
     1924    9076    1924       9084  pty3    133715 13:41:54 
/usr/bin/sleep
Close anyway?
---------------------------

I tried to filter the output with cut but that doesn't work because the STIME column may contain a space. Of course I could filter it myself... I can also make the ps command a configurable preference.

@sschuberth
Copy link

I see. In that case procps's output is certainly better than nothing as it gives the process name so you'll like be able to locate and close it. Thanks for implementing this feature!

(Feel free to close this issue as I cannot do it although the original report on Google Code was mine because the GoogleCodeExported took ownership of this issue.)

@mintty
Copy link
Owner

mintty commented Jul 16, 2015

I like closing issues :)
Current approach: procps -o pid,ruser=USER -o comm 2> /dev/null || ps -ef
in order to work whether procps is installed or not; to be fed into popen().
I assume then that you do not wish a configurable ps command.
Thanks for discussing the details.

@mintty
Copy link
Owner

mintty commented Oct 14, 2018

Uploaded to repository: the process list for exit confirmation is now created from the /proc filesystem, without starting an external ps process.
This speeds up the information pop-up and likely addresses https://cygwin.com/ml/cygwin/2018-10/msg00058.html in case of aggressive virus scanners.
It also adds the opportunity to include the WINPID in the listing.

@mintty
Copy link
Owner

mintty commented Nov 10, 2018

Released 2.9.4; do spawn an external process (ps) anymore, display of process list is faster and blocking in case of aggressive virus scanners is avoided.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants