CTRL-C does not work in Cygwin when using pipes

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

CTRL-C does not work in Cygwin when using pipes

Bill Smith
Hi,

I have observed that CTRL-C does not work when using pipes in Cygwin.  Is this a bug?  Or is there an issue with my stty settings?


If I do this:

perl -e 'while(1) {sleep 1;}'

CTRL-C works



If I do:

echo foo | perl -e 'while(1) {sleep 1;}'

CTRL-C does not work.  I have to use Task Manager to kill the perl program.


I've reproduce the behavior with other Cygwin programs so it's not specific to perl. You could do:

cat <some largefile> | more

to get the same behavior.  I used versions 2.0.1(0.287/5/3) 2015-04-30 18:13 &  2.4.0(0.292/5/3) 2015-12-17 21:59 to reproduce the issue.

Thanks,
--Bill

--
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

Reply | Threaded
Open this post in threaded view
|

Re: CTRL-C does not work in Cygwin when using pipes

Warren Young-2
On Dec 29, 2015, at 1:03 PM, Bill Smith <[hidden email]> wrote:
>
> echo foo | perl -e 'while(1) {sleep 1;}'
>
> CTRL-C does not work.  I have to use Task Manager to kill the perl program.

Works for me on Windows 10, under both the Cygwin Terminal (mintty) and in a raw cmd.exe window.

You’ll have to narrow the conditions.
--
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

Reply | Threaded
Open this post in threaded view
|

Re: CTRL-C does not work in Cygwin when using pipes

Roger Wells
On 12/29/2015 03:29 PM, Warren Young wrote:
> On Dec 29, 2015, at 1:03 PM, Bill Smith <[hidden email]> wrote:
>>
>> echo foo | perl -e 'while(1) {sleep 1;}'
>>
>> CTRL-C does not work.  I have to use Task Manager to kill the perl program.
>
> Works for me on Windows 10, under both the Cygwin Terminal (mintty) and in a raw cmd.exe window.
>

a bit more:
windows 10, mintty, works as hoped.
windows 10, bash, observe what the OP reported originally

HTH

> You’ll have to narrow the conditions.
> --
> 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
>
>


--
Roger Wells, P.E.
leidos
221 Third St
Newport, RI 02840
401-847-4210 (voice)
401-849-1585 (fax)
[hidden email]

--
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

Reply | Threaded
Open this post in threaded view
|

RE: CTRL-C does not work in Cygwin when using pipes

Bill Smith
In reply to this post by Bill Smith
[Oops, apologies if I messed up the threading as I wasn't subscribed to the list and noticed there were some replies.]


On 12/29/2015 04:07 PM, Roger Wells wrote:
> a bit more:
> windows 10, mintty, works as hoped.
> windows 10, bash, observe what the OP reported originally

Yes, I'm trying to do this with the standard shell, bash.  We have tried using mintty or the xterm version but there were other issues.  Thanks.

--
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

Reply | Threaded
Open this post in threaded view
|

Re: CTRL-C does not work in Cygwin when using pipes

Michael Enright
On Tue, Dec 29, 2015 at 2:31 PM, Bill Smith wrote:
> Yes, I'm trying to do this with the standard shell, bash.  We have tried using mintty or the xterm version but there were other issues.

The above implies something but I'm not sure what it is. Can you give
more detail?

mintty and xterm are terminal emulators which can't do much without a
shell inside them.
bash is among the valid shells you can use in mintty or xterm or rxvt.

The default "Cygwin terminal" icon if you set up a minimal Cygwin
installation is mintty serving as a terminal for bash.

So when you say you are trying with the standard shell I'm with you up
to the part where you say, "We have tried using mintty...but there
were other issues" because I use those together.

And since I have chosen to participate in this thread, I tried the
command in question. The success of my attempt does not mean that I
don't believe there's a problem. My setup is Windows 7/64 in a VM,
running 32-bit cygwin, mintty terminal and bash.

--
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

Reply | Threaded
Open this post in threaded view
|

Re: CTRL-C does not work in Cygwin when using pipes

Warren Young-2
In reply to this post by Bill Smith
On Dec 29, 2015, at 3:31 PM, Bill Smith <[hidden email]> wrote:
>
> I'm trying to do this with the standard shell, bash.  We have tried using mintty or the xterm version but there were other issues.

Michael is correct: the shell and the terminal are two separate programs.  Your problem isn’t with bash, it’s with the Windows native console.

If the Windows native console were the best way to run an interactive Cygwin command shell, Cygwin wouldn’t default to mintty these days.

That said, Cygwin *used* to run Bash in the Windows Console by default, and I don’t recall Ctrl-C failing in that case.  So, I guess something changed in the cygwin1.dll terminal I/O handling which breaks Ctrl-C handling while a pipe is running.

While waiting for a fix, maybe a more productive way to solve your problem is to address these “issues” you’re having with mintty.  There’s something to be said for running with the standard environment.
--
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

Reply | Threaded
Open this post in threaded view
|

Re: CTRL-C does not work in Cygwin when using pipes

Michael Enright
In reply to this post by Michael Enright
On Tue, Dec 29, 2015 at 2:57 PM, Michael Enright <[hidden email]> wrote:
> And since I have chosen to participate in this thread, I tried the
> command in question. The success of my attempt does not mean that I
> don't believe there's a problem. My setup is Windows 7/64 in a VM,
> running 32-bit cygwin, mintty terminal and bash.

Also Windows 10 (not yet updated to November update) 64-bit running
64-bit Cygwin, minty and bash was okay.
Also, for fun, I tried this in Power Shell
> $env:Path += ";C:\cygwin64\bin"
> bash
$ perl -e 'while(1) {sleep 1;}

I was able to control-C out of this.

(And now we all know the way to augment the path in Power Shell!)

Not a recommended way to use Cygwin tools but I thought it was worth adding.

--
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

Reply | Threaded
Open this post in threaded view
|

Re: CTRL-C does not work in Cygwin when using pipes

Michael Enright
On Wed, Dec 30, 2015 at 1:03 AM, Michael Enright  wrote:

> On Tue, Dec 29, 2015 at 2:57 PM, Michael Enright  wrote:
>> And since I have chosen to participate in this thread, I tried the
>> command in question. The success of my attempt does not mean that I
>> don't believe there's a problem. My setup is Windows 7/64 in a VM,
>> running 32-bit cygwin, mintty terminal and bash.
>
> Also Windows 10 (not yet updated to November update) 64-bit running
> 64-bit Cygwin, minty and bash was okay.
> Also, for fun, I tried this in Power Shell
>> $env:Path += ";C:\cygwin64\bin"
>> bash
> $ perl -e 'while(1) {sleep 1;}
>
> I was able to control-C out of this.
>
> (And now we all know the way to augment the path in Power Shell!)
>
> Not a recommended way to use Cygwin tools but I thought it was worth adding.

Okay on review the above is not faithful to the problem statement and
so I tried some variations:
In bash inside Power Shell,
 echo foo | perl -e 'while(1) {sleep 1;}'
Will hang.

The same command pipeline, under the condition of having the path
augmented as above, will perform as expected and control-C will stop
the program.

--
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