Link to home
Start Free TrialLog in
Avatar of matthewsmith
matthewsmith

asked on

Process Group question

I have an MFC based (gui) app, that creates anonymous pipes to a console app that it communicates with.  I have to be able to kill off the console app from the MFC app if the console app gets hung.  This works fine if I communicate directly with the console app, because I can call TerminateProcess() to kill it off if need be.  However, I need to implement support for a console app that has a pre-processing front-end app.  Basically, this pre-processing app parses through the work load, and determines the proper console app to start up to process the work load.  So I need to do this: use CreateProcess() to execute the pre-processing app (which is a console app as well), and that process in turn executes another process.  HOWEVER, if I kill off the pre-processing app, it leaves the workload-processing console app hanging around in the background.  Is there a way to kill off the pre-processing app along with any child processes?  The concept I'm talking about here is a process group.  I tried using CreateProcess() with the CREATE_NEW_PROCESS_GROUP flag, and then using GenerateConsoleCtrlEvent() to send a CTRL_BREAK event to the pre-processing app, but it doesn't work for me.  Any ideas?

thanks
-Matt Smith
Avatar of jkr
jkr
Flag of Germany image

Isn't that basically the same as you asked in https://www.experts-exchange.com/jsp/qShow.jsp?ta=mfc&qid=10203214  ?
ASKER CERTIFIED SOLUTION
Avatar of NickRepin
NickRepin

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of matthewsmith
matthewsmith

ASKER

To JKR:

Yes, I did ask the same question before.  I'm not sure why it says 'accepted answer', because I don't remember accepting it, and it certainly didn't ever work for me.

To NickRepin:

I was thinking along those lines.  This sounds like a reasonable solution.  I'll try implementing it tomorrow morning and let you know.  Thanks!


cheers,
-Matt Smith
I tested it before I posted the answer here.
One other problem I'm having Nick: Everything works fine with the process group, but when I call AllocConsole(), it shows the console window.  Can I have it be hidden some how?  Thanks!

cheers,
-Matt