Home All Groups Group Topic Archive Search About

How to signal process

Author
31 Mar 2006 6:58 PM
William Stacey [MVP]
How can you signal Ctrl-C to a managed process (i.e. process is hosting
cmd.exe)?  TIA

--
William Stacey [MVP]

Author
31 Mar 2006 8:35 PM
Mattias Sjögren
>How can you signal Ctrl-C to a managed process (i.e. process is hosting
>cmd.exe)?

If I understand the question correctly, you can call
GenerateConsoleCtrlEvent(CTRL_C_EVENT). It should work for any console
process, managed or not.

http://msdn.microsoft.com/library/en-us/dllproc/base/generateconsolectrlevent.asp


Mattias

--
Mattias Sjögren [C# MVP]  mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Author
31 Mar 2006 9:32 PM
William Stacey [MVP]
Thanks Mattias.  Know how to get the "dwProcessGroupId ", when all I have is
the Process.Id ?  TIA

--
William Stacey [MVP]

"Mattias Sjögren" <mattias.dont.want.spam@mvps.org> wrote in message
news:eLnioJQVGHA.1344@TK2MSFTNGP15.phx.gbl...
|
| >How can you signal Ctrl-C to a managed process (i.e. process is hosting
| >cmd.exe)?
|
| If I understand the question correctly, you can call
| GenerateConsoleCtrlEvent(CTRL_C_EVENT). It should work for any console
| process, managed or not.
|
|
http://msdn.microsoft.com/library/en-us/dllproc/base/generateconsolectrlevent.asp
Show quote
|
|
| Mattias
|
| --
| Mattias Sjögren [C# MVP]  mattias @ mvps.org
| http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
| Please reply only to the newsgroup.
Author
1 Apr 2006 8:51 AM
Vadym Stetsyak
Hello, William!

According to docs:
"
dwProcessGroupId
Identifier of the process group to receive the signal. A process group is created when the CREATE_NEW_PROCESS_GROUP flag is specified in a call to the CreateProcess function. The process identifier of the new process is also the process group identifier of a new process group. The process group includes all processes that are descendants of the root process. Only those processes in the group that share the same console as the calling process receive the signal. In other words, if a process in the group creates a new console, that process does not receive the signal, nor do its descendants."

Can you describe your scenario?

If you have parent process and descendants, then parent process id will be groupId.
If there is single process with console then there is no need to specify dwProcessGroupId

--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com

AddThis Social Bookmark Button