Solved

process problem

Posted on 1998-10-14
9
632 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
Comment Utility
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
Comment Utility
Is the 3rd process a GUI application or a console process?
0
 

Expert Comment

by:clance
Comment Utility
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
 

Expert Comment

by:clance
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 1

Expert Comment

by:msa092298
Comment Utility
dwCreationFlags should contain CREATE_NEW_PROCESS_GROUP

0
 

Author Comment

by:M031097
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
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 user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now