471,325 Members | 1,442 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,325 software developers and data experts.

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 8294
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.com

"Frank" <fr***@frank.com> 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.Exit 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.StandardInput to send a ctrl+c to the app
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Frank" <fr***@frank.com> 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.machin AT dot.state.fl.us>
schreef in bericht news:O9****************@tk2msftngp13.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.Exit 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.StandardInput to send a ctrl+c to the app
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Frank" <fr***@frank.com> 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.com> schreef
in bericht news:e%****************@TK2MSFTNGP11.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.com

"Frank" <fr***@frank.com> 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.com> 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.machin AT dot.state.fl.us>
schreef in bericht news:O9****************@tk2msftngp13.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.Exit 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.StandardInput to send a ctrl+c to the app
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Frank" <fr***@frank.com> 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.machin AT dot.state.fl.us>
schreef in bericht news:eA**************@TK2MSFTNGP14.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.com> 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.machin AT dot.state.fl.us>
schreef in bericht news:O9****************@tk2msftngp13.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.Exit 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.StandardInput to send a ctrl+c to the app
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Frank" <fr***@frank.com> 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.com> 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.machin AT dot.state.fl.us>
schreef in bericht news:eA**************@TK2MSFTNGP14.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.com> 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.machin AT dot.state.fl.us>
schreef in bericht news:O9****************@tk2msftngp13.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.Exit 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.StandardInput to send a ctrl+c to the app
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Frank" <fr***@frank.com> 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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by William F. Robertson, Jr. | last post: by
6 posts views Thread by - Steve - | last post: by
6 posts views Thread by Tim Chase | last post: by
10 posts views Thread by Philip Pemberton | last post: by
5 posts views Thread by Jon Davis | last post: by

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.