delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/06/03/11:38:05

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
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
content-class: urn:content-classes:message
MIME-Version: 1.0
Subject: Bash, Windows Console programs, and Ctrl-C
Date: Fri, 3 Jun 2005 11:37:56 -0400
Message-ID: <927DD5EB74B7114EAF78D7D40DDE10F0D01737@ad-email1.ad.mc.com>
From: "Pilhofer, Frank" <fpilhofe AT mc DOT com>
To: <cygwin AT cygwin DOT com>
X-IsSubscribed: yes
Note-from-DJ: This may be spam

------_=_NextPart_001_01C56852.36F5E0EE
Content-Type: text/plain;
	charset="US-ASCII"
Content-Transfer-Encoding: quoted-printable

Hi,

I am using Cygwin on Windows 2000.

I am running Win32 command-line programs from bash. In
these programs, I'd like to react to Ctrl-C, using Win32's
SetConsoleCtrlHandler() function.

See, for example, the attached program (compile with MinGW
or MS C++): When pressing Ctrl-C, I expect the program to
continue. For demonstration, it should print "Sleeping ...",
and wait for a while, before exiting.

This works fine when I run the program from a Windows "cmd"
command-line shell.

It does not work when I run the program from Cygwin's bash:
sometimes, I see the "Sleeping" message, but then the program
is interrupted, and never completes cleanly.

This almost looks as if the program is sent a separate signal,
but adding a signal handler (using signal (SIGINT, ...);) does
not make a difference.

"stty intr ^y" also did not have an effect.

Any suggestions?

Thanks,
Frank


------_=_NextPart_001_01C56852.36F5E0EE
Content-Type: application/octet-stream;
	name="ctrlc.cpp"
Content-Transfer-Encoding: base64
Content-Description: ctrlc.cpp
Content-Disposition: attachment;
	filename="ctrlc.cpp"

I2luY2x1ZGUgPGlvc3RyZWFtPg0KI2luY2x1ZGUgPHdpbmRvd3MuaD4NCg0K
dm9sYXRpbGUgYm9vbCBoYWRDdHJsQzsNCg0KQk9PTCBXSU5BUEkNCk15Q3Ry
bENIYW5kbGVyIChEV09SRCB0eXBlKQ0Kew0KICBpZiAodHlwZSAhPSBDVFJM
X0NfRVZFTlQgJiYgdHlwZSAhPSBDVFJMX0JSRUFLX0VWRU5UKSB7DQogICAg
cmV0dXJuIDA7DQogIH0NCg0KICBoYWRDdHJsQyA9IHRydWU7DQogIHJldHVy
biAxOw0KfQ0KDQppbnQNCm1haW4gKCkNCnsNCiAgaGFkQ3RybEMgPSBmYWxz
ZTsNCiAgU2V0Q29uc29sZUN0cmxIYW5kbGVyIChNeUN0cmxDSGFuZGxlciwg
MSk7DQoNCiAgc3RkOjpjb3V0IDw8ICJXYWl0aW5nIC4uLiIgPDwgc3RkOjpm
bHVzaDsNCg0KICB3aGlsZSAoIWhhZEN0cmxDKSB7DQogICAgU2xlZXAgKDEw
MDApOw0KICAgIHN0ZDo6Y291dCA8PCAiLiIgPDwgc3RkOjpmbHVzaDsNCiAg
fQ0KDQogIHN0ZDo6Y291dCA8PCAiIGRvbmUuIiA8PCBzdGQ6OmVuZGw7DQoN
CiAgc3RkOjpjb3V0IDw8ICJTbGVlcGluZyAuLi4gIiA8PCBzdGQ6OmZsdXNo
Ow0KICBmb3IgKGludCBpPTA7IGk8NTA7IGkrKykgew0KICAgIFNsZWVwICgx
MDApOw0KICB9DQogIHN0ZDo6Y291dCA8PCAiZG9uZS4iIDw8IHN0ZDo6Zmx1
c2g7DQoNCiAgcmV0dXJuIDA7DQp9DQoNCg==


------_=_NextPart_001_01C56852.36F5E0EE
Content-Type: text/plain; charset=us-ascii

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

- Raw text -


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