473,795 Members | 2,667 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

gracefully end console app

Hi,
I have a console app that I want to stop gracefully by another program. The
console app already has code to intercept control-c and logoff and so on.
But how do I send a control-c to that console app from another program? The
console application is started with a Process class.

Thanks
Frank
Dec 27 '05 #1
7 8421
Frank,

Why not expose a remoting endpoint which would have a method which will
call Exit on the Environment class?

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Frank" <fr***@frank.co m> wrote in message
news:do******** **@news6.zwoll1 .ov.home.nl...
Hi,
I have a console app that I want to stop gracefully by another program.
The console app already has code to intercept control-c and logoff and so
on. But how do I send a control-c to that console app from another
program? The console application is started with a Process class.

Thanks
Frank

Dec 27 '05 #2
Hi,
The Console app can expose several ways to communicate with it , like :
1- TCP port
2- Named piped
3- Remoting

Any of these can be used to send a "terminate" signal , then you can call
Environment.Exi t or Process.Kill to force it to terminate, or do as needed
to gracefully terminate it.

In case you do not have access to modify the app you could use
Process.Standar dInput to send a ctrl+c to the app
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Frank" <fr***@frank.co m> wrote in message
news:do******** **@news6.zwoll1 .ov.home.nl...
Hi,
I have a console app that I want to stop gracefully by another program.
The console app already has code to intercept control-c and logoff and so
on. But how do I send a control-c to that console app from another
program? The console application is started with a Process class.

Thanks
Frank

Dec 27 '05 #3
Sending ctrl+c to standardinput does not seem to work. I don't know why not.
thanks
Frank

"Ignacio Machin ( .NET/ C# MVP )" <ignacio.mach in AT dot.state.fl.us >
schreef in bericht news:O9******** ********@tk2msf tngp13.phx.gbl. ..
Hi,
The Console app can expose several ways to communicate with it , like :
1- TCP port
2- Named piped
3- Remoting

Any of these can be used to send a "terminate" signal , then you can call
Environment.Exi t or Process.Kill to force it to terminate, or do as
needed to gracefully terminate it.

In case you do not have access to modify the app you could use
Process.Standar dInput to send a ctrl+c to the app
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Frank" <fr***@frank.co m> wrote in message
news:do******** **@news6.zwoll1 .ov.home.nl...
Hi,
I have a console app that I want to stop gracefully by another program.
The console app already has code to intercept control-c and logoff and so
on. But how do I send a control-c to that console app from another
program? The console application is started with a Process class.

Thanks
Frank


Dec 27 '05 #4
Yes, thats on my list
Thanks
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> schreef
in bericht news:e%******** ********@TK2MSF TNGP11.phx.gbl. ..
Frank,

Why not expose a remoting endpoint which would have a method which will
call Exit on the Environment class?

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Frank" <fr***@frank.co m> wrote in message
news:do******** **@news6.zwoll1 .ov.home.nl...
Hi,
I have a console app that I want to stop gracefully by another program.
The console app already has code to intercept control-c and logoff and so
on. But how do I send a control-c to that console app from another
program? The console application is started with a Process class.

Thanks
Frank


Dec 27 '05 #5
Hi,

Does it works if you send any other character?

maybe you are not sending the correct sequence.

what about the other options I presented you with?
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Frank" <fr***@frank.co m> wrote in message
news:do******** **@news4.zwoll1 .ov.home.nl...
Sending ctrl+c to standardinput does not seem to work. I don't know why
not.
thanks
Frank

"Ignacio Machin ( .NET/ C# MVP )" <ignacio.mach in AT dot.state.fl.us >
schreef in bericht news:O9******** ********@tk2msf tngp13.phx.gbl. ..
Hi,
The Console app can expose several ways to communicate with it , like :
1- TCP port
2- Named piped
3- Remoting

Any of these can be used to send a "terminate" signal , then you can call
Environment.Exi t or Process.Kill to force it to terminate, or do as
needed to gracefully terminate it.

In case you do not have access to modify the app you could use
Process.Standar dInput to send a ctrl+c to the app
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Frank" <fr***@frank.co m> wrote in message
news:do******** **@news6.zwoll1 .ov.home.nl...
Hi,
I have a console app that I want to stop gracefully by another program.
The console app already has code to intercept control-c and logoff and
so on. But how do I send a control-c to that console app from another
program? The console application is started with a Process class.

Thanks
Frank



Dec 27 '05 #6
Hello,
I am sending a hex 3.
The console app does not have a read in it.
Don't need to, if I do a ctrl-c or close the window with the X in the
topright corner it stops gracefully.
Regards
Frank
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.mach in AT dot.state.fl.us >
schreef in bericht news:eA******** ******@TK2MSFTN GP14.phx.gbl...
Hi,

Does it works if you send any other character?

maybe you are not sending the correct sequence.

what about the other options I presented you with?
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Frank" <fr***@frank.co m> wrote in message
news:do******** **@news4.zwoll1 .ov.home.nl...
Sending ctrl+c to standardinput does not seem to work. I don't know why
not.
thanks
Frank

"Ignacio Machin ( .NET/ C# MVP )" <ignacio.mach in AT dot.state.fl.us >
schreef in bericht news:O9******** ********@tk2msf tngp13.phx.gbl. ..
Hi,
The Console app can expose several ways to communicate with it , like :
1- TCP port
2- Named piped
3- Remoting

Any of these can be used to send a "terminate" signal , then you can
call Environment.Exi t or Process.Kill to force it to terminate, or do
as needed to gracefully terminate it.

In case you do not have access to modify the app you could use
Process.Standar dInput to send a ctrl+c to the app
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Frank" <fr***@frank.co m> wrote in message
news:do******** **@news6.zwoll1 .ov.home.nl...
Hi,
I have a console app that I want to stop gracefully by another program.
The console app already has code to intercept control-c and logoff and
so on. But how do I send a control-c to that console app from another
program? The console application is started with a Process class.

Thanks
Frank



Dec 27 '05 #7
Hi,

Well, what about a Process.Kill ?

Not very gracefully, but ... :)

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Frank" <fr***@frank.co m> wrote in message
news:do******** **@news2.zwoll1 .ov.home.nl...
Hello,
I am sending a hex 3.
The console app does not have a read in it.
Don't need to, if I do a ctrl-c or close the window with the X in the
topright corner it stops gracefully.
Regards
Frank
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.mach in AT dot.state.fl.us >
schreef in bericht news:eA******** ******@TK2MSFTN GP14.phx.gbl...
Hi,

Does it works if you send any other character?

maybe you are not sending the correct sequence.

what about the other options I presented you with?
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Frank" <fr***@frank.co m> wrote in message
news:do******** **@news4.zwoll1 .ov.home.nl...
Sending ctrl+c to standardinput does not seem to work. I don't know why
not.
thanks
Frank

"Ignacio Machin ( .NET/ C# MVP )" <ignacio.mach in AT dot.state.fl.us >
schreef in bericht news:O9******** ********@tk2msf tngp13.phx.gbl. ..
Hi,
The Console app can expose several ways to communicate with it , like :
1- TCP port
2- Named piped
3- Remoting

Any of these can be used to send a "terminate" signal , then you can
call Environment.Exi t or Process.Kill to force it to terminate, or do
as needed to gracefully terminate it.

In case you do not have access to modify the app you could use
Process.Standar dInput to send a ctrl+c to the app
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Frank" <fr***@frank.co m> wrote in message
news:do******** **@news6.zwoll1 .ov.home.nl...
> Hi,
> I have a console app that I want to stop gracefully by another
> program. The console app already has code to intercept control-c and
> logoff and so on. But how do I send a control-c to that console app
> from another program? The console application is started with a
> Process class.
>
> Thanks
> Frank
>



Dec 27 '05 #8

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

Similar topics

4
5743
by: KB | last post by:
Hi, I want to write a Python script that controls and automates a Windows GUI computation program. My problem is that I do not know how to quit the Windows GUI program gracefully with a command (program's or Python) in Cygwin. 'kill' or CTRL-C command in Cygwin does not finish it gracefully, meaning that some outputs do not come out normally. The only thing I know is to click 'File-Exit' menu, but
2
1776
by: Gary | last post by:
Hi, there, I have an application running on remote machine, and would like to close it gracefully. Like a human go to there, push the stop button, and close it after several seconds. How to implement that in C#? Any suggestion? Thanks lot, Gary
4
1694
by: William F. Robertson, Jr. | last post by:
One of my developers came to me with this question and I don't have an answer for them. The only suggestion I had for them was to change the return to a output parameter and put a try catch around it and look for the output parameter to have a value. I would have thought this should have been posted in the sql newgroups, but I know exactly what they would say, and they would be correct. But when using asp.net ado.net command object. I...
6
1769
by: - Steve - | last post by:
I'm using Forms Based Authentication. I've written my code so that when a user does something but has timed out, it gracefully logs them out and asks them to log back on. I do this with . . Session.Abandon() Response.Redirect("logon.aspx")
6
5691
by: Mark | last post by:
Hello, I'm trying to handle HttpRequestValidationException. If a hacker enters certain values into a textbox, like "<script>", it will trigger this error. I understand why .Net has this, but I need a way to gracefully handle it. Ideally the app would catch it as invalid input, and then return control to the user instead of throwing an exception. This is a problem is a legitimate user enters it into a long description box as part of a rare,...
6
3057
by: Tim Chase | last post by:
While working on a Jumble-esque program, I was trying to get a string into a character array. Unfortunately, it seems to choke on the following import random s = "abcefg" random.shuffle(s) returning
10
3661
by: Philip Pemberton | last post by:
Hi, I'm currently playing around with a little spam filter for my Linksys NSLU2 (I would have used Spamassassin but that's slow even on my 2GHz Athlon64 - on a 266MHz XScale it's likely to be intolerably slow). As part of that, I'm keeping track of the DNSBL blocklists that are being queried using a dynamically-allocated array. When a new DNSBL zone is added to the zone array, I use realloc() to increase the amount of memory available...
5
8390
by: Jon Davis | last post by:
Is there such a thing as a Windows standard for killing a console app that is monitored by a System.Diagnostics.Process object? I'm hosting several C# console apps in a C# Windows service and would like to standardize on a graceful termination method when the Windows service stops. Jon
4
2960
!NoItAll
by: !NoItAll | last post by:
I have a program that needs to access the files that are open by another program on the computer. When my application comes up I can easily see if the other application is running with the .net Process.GetProcessesByName method Dim MyProcesses() as Process = GetProcessesByName("AnApplication") For Each Instance as Process in MyProcesses If MsgBox("application is running - do you want to end it?", MsgBoxStyle.YesNo or...
0
9672
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9519
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
10436
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...
1
10163
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,...
0
10000
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6780
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
5436
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...
2
3722
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2920
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.