Solved

process problem

Posted on 1998-10-14
9
639 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
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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
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 goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

820 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