473,804 Members | 3,272 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Send ctrl-c

How do you send Ctrl-C to a standard input stream? Just sending 03 does not
work.

--
William Stacey [MVP]

Mar 31 '06 #1
3 12717

"William Stacey [MVP]" <wi************ @gmail.com> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
How do you send Ctrl-C to a standard input stream? Just sending 03 does
not
work.


Yes it does but that isn't what you mean is it.

What you mean is how can you send an interrupt over a stream and that can't
be done. Ctrl-C is only magic if some code somewhere decides to make it so
and that code is not in any framework I/O class.

What happens normally depends on the app type but basically the app NEVER
receives a CTRL-C on ANY stream.

If your app is a forms app then ctrl-c is just another key event and there
is no standard input stream connected to the keyboard in any way.

If your app is a console app the console receives the key events and sends
them to your stdin but when it sees ctrl-c it interrupts your app instead.
Mar 31 '06 #2
| If your app is a console app the console receives the key events and sends
| them to your stdin but when it sees ctrl-c it interrupts your app instead.

Thanks Nick. That makes sense. But the case of cmd.exe, for example,
cntrl-c at the c:\ prompt will just bring you to another prompt and not
close down cmd.exe. And if you do dir /s and do a ctrl-c, it interupts the
dir internal command, so it seems as if console is passing something to
cmd.exe, not just killing the process. What am I missing?
Mar 31 '06 #3

"William Stacey [MVP]" <wi************ @gmail.com> wrote in message
news:uj******** ******@TK2MSFTN GP11.phx.gbl...
| If your app is a console app the console receives the key events and
sends
| them to your stdin but when it sees ctrl-c it interrupts your app
instead.

Thanks Nick. That makes sense. But the case of cmd.exe, for example,
cntrl-c at the c:\ prompt will just bring you to another prompt and not
close down cmd.exe. And if you do dir /s and do a ctrl-c, it interupts
the
dir internal command, so it seems as if console is passing something to
cmd.exe, not just killing the process. What am I missing?


You can "catch" (not C# catch) the interrupt and ignore it or pass it on or
whatever - this is what cmd.exe does.

This is one of those cases where having come from C,C++ or UNIX helps.

see
http://msdn.microsoft.com/library/de...crt_signal.asp
and SIGINT

I do not know the Windows call to send a signal because my C++ is from UNIX
where it is the kill(pid,signal ) method which doesn't seem to exist in
windows but I'm sure that there is an equivalent
Mar 31 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
9458
by: jas | last post by:
I have a basic client/server socket situation setup....where the server accepts a connection and then waits for commands. On the client side, I create a socket, connect to the server...then I pass the socket to a class which just reads from the socket (in a thread). class Reader(Thread): def run(self): while 1:
2
6282
by: Gary | last post by:
I am trying to use the "System.Windows.Forms.SendKeys" class for triggering the Ctrl+P key. Syntax: System.Windows.Forms.SendKeys.Send("^(P)"); This is not working ..what could be the reason..? Situation: I have a menu in my form, which is given a short key "Ctrl+P", now when the
6
31122
by: Gary | last post by:
Hi, I am trying to use the "System.Windows.Forms.SendKeys" class for triggering the Ctrl+P key. Syntax: System.Windows.Forms.SendKeys.Send("^(P)") This is not working ..what could be the reason..?
3
8261
by: Str Noetika | last post by:
Hi, How can I send ctrl keys (like ctrl A, ctrl C) from a VB application to another existing application (like word, excel...) ? I tried to send postmessages like postmessage(hwnd,WM_KEYDOWN,vk_control,code) postmessage(hwnd,WM_KEYDOWN,"A",code) postmessage(hwnd,WM_KEYUP,"A",code) postmessage(hwnd,WM_KEYUP,vk_control,code)
4
4179
by: F.C. | last post by:
Hi code gurus ! I'm creating a front end for a DOS application using VB .Net. I launch this DOS app using System.Diagnostics.Process : myProcess.StartInfo.FileName = "myapp.exe" myProcess.StartInfo.UseShellExecute = False myProcess.StartInfo.CreateNoWindow = True myProcess.StartInfo.RedirectStandardInput = True myProcess.StartInfo.RedirectStandardOutput = True
0
3950
by: B Loggins | last post by:
Hi everyone, thanks in advance fo any help on this issue. I'm trying to "wrap" cmd.exe. That is, I'm redirecting StandardInput and StandardOutput for a cmd.exe process and I'm sending StdOut to a RichTextBox where I'm doing stuff to the text. I'm also passing the characters typed to the RichTextBox to StandardInput for cmd.exe. This is all working quite well, but the problem is that I cannot get cmd.exe to process Ctrl-C correctly. ...
2
15942
by: abhay | last post by:
hi,i m interfacing gsm modem to my microcontroller.i need to send sms through it. i am using AT commands for that.the command to send sms (AT+ CMGS) terminates with ctrl-Z.now in my program i hav tried all ways to send ctrl-Z at end of my sms.but it takes this as a character or string only.also i tried with ascii value of ctrl-Z but of no use. i am able to see the transmitted commands on hyper-terminal through
0
1522
by: misbahCU | last post by:
I am trying to make a script so that it can automate the basic functionality of the router like the logins and the password recovery. For this i am required to send the Ctrl+z, i tried using the ASCII codes, but its not working with the ASCII codes for Ctrl+z.
3
4030
by: zlf | last post by:
Hello I'm writing testcase for my console application. One testcase requires to test press Ctrl+C while the application is running. How to send Ctrl+C while running application through System.Diagnostics.Process? I know I can simulate input through p.StandardInput.WriteLine, but I do not know what exactly input string represents "Ctrl+C". Thanks
0
9588
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10589
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10340
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10327
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7625
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6857
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5527
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4302
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3828
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.