Solved

process problem

Posted on 1998-10-14
9
640 Views
Last Modified: 2012-06-27
Hi all!

I have a probelm with processes
I use CreateProcess to start the new process then I use WaitForSingleObject to wait for it to end. Now the problem is that this new (2nd) process also creates process (3rd).
What happens is that 2nd is terminated before 3rd, and this one seems to just hang around in memory.

the 2nd process is a program which I have no control over, some one else wrote it.

so the main question is:
how can I make sure that all subprocesses are finished before I terminate the 2nd process?
0
Comment
Question by:M031097
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 

Expert Comment

by:jbalagop
ID: 1175129
The above was a comment. also if you want to read from the port,
once you have created the the file using CreateFile(), it returns the handle to this communication device. You may read or write then. Also, make sure you have status checking on the port (incase the connection is reset).


0
 
LVL 86

Expert Comment

by:jkr
ID: 1175130
Is the 3rd process a GUI application or a console process?
0
 

Expert Comment

by:clance
ID: 1175131
Did you write the 3rd program?  Please explain what type of program it is (console app, Win 32 app, MFC app, etc.), what it's doing, and why you would want to kill it in the middle of whatever it's doing.

I'm thinking that if it's a Windows app of come kind you can send the 3rd process a WM_CLOSE message based on it's main window's title.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Expert Comment

by:clance
ID: 1175132
Did you write the 3rd program?  Please explain what type of program it is (console app, Win 32 app, MFC app, etc.), what it's doing, and why you would want to kill it in the middle of whatever it's doing.

I'm thinking that if it's a Windows app of come kind you can send the 3rd process a WM_CLOSE message based on it's main window's title.
0
 
LVL 1

Expert Comment

by:msa092298
ID: 1175133
dwCreationFlags should contain CREATE_NEW_PROCESS_GROUP

0
 

Author Comment

by:M031097
ID: 1175134
the first program is the only one I have created, the 2nd could basically be anything, the 3rd is a GUI app and these dialogs are still showing while the other two programs are terminated.
CREATE_NEW_PROCESS_GROUP is used but doesn't work.

0
 

Expert Comment

by:clance
ID: 1175135
CREATE_NEW_PROCESS_GROUP is a hold over from UNIX and is only supported for Console Apps.
0
 
LVL 2

Accepted Solution

by:
mnguyen021997 earned 150 total points
ID: 1175136
try using createprocess with the debug_process flag which essentially makes you a debugger of the process created.  it also gives you notification of other process that are spawned by the debugged process. these notifications should be sufficient to allow you to track the lifetime of these processes.
0
 

Author Comment

by:M031097
ID: 1175137
I haven't had time to try this, but I will accept your answer anyway. Not your fault the boss is stealing time from me ;-)
thanks all
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

736 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question