Solved

process problem

Posted on 1998-10-14
9
636 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
maze travler 6 55
IdTelnet1DataAvailable handler freezes the Application 4 74
How to copy an image file into clipboard C/C++? 1 168
How to split this in C++ 4 101
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
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…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

808 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