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

Prompt about closing window when Close [X] button is pressed #907

Closed
dxdemetriou opened this issue Sep 5, 2019 · 11 comments
Closed

Prompt about closing window when Close [X] button is pressed #907

dxdemetriou opened this issue Sep 5, 2019 · 11 comments
Labels

Comments

@dxdemetriou
Copy link

dxdemetriou commented Sep 5, 2019

There is a feature "Prompt about running processes on close" but is not always working on Cygwin 3 (it always worked from Cygwin 2,6).

Is it possible to always prompt about closing the window if the X button is pressed?

About ALT+F4 I have used this:
KeyFunctions=d:echo -n date``;A+F4:;CA+F12:break;-:"minus"
in .minttyrc

@mintty
Copy link
Owner

mintty commented Sep 5, 2019

The prompt is only shown if the child shell has invoked further commands. This has not changed with cygwin versions. If you see any specific inconsistent or otherwise undesired behaviour, describe a complete reproducible test case.
User-defining Alt+F4 does not affect clicking on the X.

@dxdemetriou
Copy link
Author

dxdemetriou commented Sep 6, 2019

According to "pstree -ap" I have this as example, when I press the [X] key on Cygwin 2+ I always get the complete list of processes, but on Cygwin 3 it's not always showing the processes and exists (I don't know yet if it's about background processes, I just have read on Cygwin's mail list about changing processes to be more Linux like). The $PPID shown on script is 13051:
├─mintty,13050 --hold=always --icon E:\Scripts\Cygwin_Scripts\\FU.ico --title CheckWOL - labs_checkFast.sh - chpCOMBINATIONS - COMBINATIONS --log...
│ └─time,13051 -f \nFINISHED . . .\tTime: %E\tCPU: %P /bin/bash --login /shell_exec.sh
│ └─bash,13052 --login /shell_exec.sh
│ ├─bash,13937 --login /shell_exec.sh
│ ├─bash,13978 --login /shell_exec.sh
│ ├─bash,14012 --login /shell_exec.sh
│ │ └─bash,14029 --login /shell_exec.sh
│ │ ├─gawk,14034 /Packets/ {print $10}
│ │ ├─ping,14030 -a L1F5 -n 1 -w1000
│ │ └─tr,14032 -d \r
│ └─bash,14023 --login /shell_exec.sh

@mintty
Copy link
Owner

mintty commented Sep 6, 2019

A reproducible test case is needed to assess the issue.

@dxdemetriou
Copy link
Author

dxdemetriou commented Sep 14, 2019

A quick example is here. You can try to press some times the [X] with ESC, and some times the window closes from the first time and other times in some time later. It seems that something crashing in list generation which never happened on older Cygwin versions, which will force me either to Cygwin 2,6 (next 2.x versions has another problem: defunct processes) or to find a way for disabling the [X] button from windows:

TESTshell.bat

`@echo off

SET pExecN=8
SET HOME=%~dp0/home/user
SET CYGWIN=nodosfilewarning
cls
start %~dp0\bin\mintty --hold=always --exec /usr/bin/time -f "\nFINISHED . . .\tTime: %%E\tCPU: %%P" /bin/bash --login /TESTshell_exec.sh
exit`

TESTshell_exec.sh

`#!/bin/sh

function funcWaitPexecN {
if [ -z "$pExecN" ] ; then pExecN=4 ; fi
if [ ! "$pExecN" == "1" ] ; then
strJobsCheck=$(jobs -r -p | wc -l)
while [ "$strJobsCheck" -ge "$pExecN" ] ; do
wait -n
strJobsCheck=$(jobs -r -p | wc -l)
done
fi
}

declare -r -a 'DLab1=(L1{'"A..Z"'}{'"1..10"'})'

function GenericStatusCheck {
echo $checkmN
sleep 1
}

function func {
{ (GenericStatusCheck) & funcWaitPexecN ; }
}

for checkmN in ${DLab1[@]} ; do func ; done
`

@mintty
Copy link
Owner

mintty commented Sep 14, 2019

What does "press the [X] with ESC" mean?
Also the test case does not work; where should it be placed? In cygwin /, I get a mintty complaining /usr/bin/time not found...
Please fix and simplify your test case.

@dxdemetriou
Copy link
Author

[X] with ESC I mean if the list with running processes is shown you have to press either CANCEL or ESC and retry. There are some random peak points whether the list is not shown and the window closes.

The time is the GNU package "time" from Cygwin installation, etherway I have just installed a clean Cygwin x86 installation and I have removed the time from script, the bug still exists. I'll try with more tests and to simplify my test case, for the time something that works:

TESTshell.bat
`@echo off

SET CYGWIN=nodosfilewarning
cls
start %~dp0\bin\mintty --hold=always --exec /bin/bash --login /TESTshell_exec.sh`

TESTshell_exec.sh
`#!/bin/sh

pExecN=8

function funcWaitPexecN {
if [ -z "$pExecN" ] ; then pExecN=4 ; fi
if [ ! "$pExecN" == "1" ] ; then
strJobsCheck=$(jobs -r -p | wc -l)
while [ "$strJobsCheck" -ge "$pExecN" ] ; do
wait -n
strJobsCheck=$(jobs -r -p | wc -l)
done
fi
}

declare -r -a 'DLab1=(L1{'"A..Z"'}{'"1..10"'})'

function GenericStatusCheck {
echo $checkmN
sleep 1
}

function func {
{ (GenericStatusCheck) & funcWaitPexecN ; }
}

for checkmN in ${DLab1[@]} ; do func ; done`

@mintty
Copy link
Owner

mintty commented Sep 15, 2019

Reproduced an issue. No need to go through a .bat file, really. And what's your complex script actually doing? Can the issue be produced easier?

@mintty mintty added the bug label Sep 15, 2019
@mintty
Copy link
Owner

mintty commented Sep 15, 2019

It was a race condition. A detected process (sleep in your case) could have terminated when retrieving its information for display...

@dxdemetriou
Copy link
Author

dxdemetriou commented Sep 15, 2019

From hta are used variables to bat which calls sh. This script actually is more complex, I just simplified it for showing the problem (that's why there are some more unneeded symbols). Let's say there are 100 computers that I'm sending specific tasks, instead of using one-by-one or all together I'm using in this example 8 computers every time (if 1 computer finished from the queue it's called the 9th, if 2 computers finished are called 9th and 10th, so we have every time 8 computers in queue without the need to wait every 8 computers to finished).

@dxdemetriou
Copy link
Author

I have just compiled and tried this commit and works perfectly, thanks

@mintty
Copy link
Owner

mintty commented Sep 26, 2019

Released 3.0.3.

@mintty mintty closed this as completed Sep 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants