Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 142189
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T07:53:49+00:00 2026-05-11T07:53:49+00:00

Basically the child process runs indefinitely until killed in the background, and I want

  • 0

Basically the child process runs indefinitely until killed in the background, and I want to clean it up when my program terminates for any reason, i.e. via the Taskmanager.

Currently I have a while (Process.GetProcessesByName(‘ParentProcess’).Count() > 0) loop and exit if the parent process isn’t running, but it seems pretty brittle, and if I wanted it to work under debugger in Visual Studio I’d have to add ‘ParentProcess.vshost’ or something.

Is there any way to make sure that the child process end without requiring the child process to know about the parent process? I’d prefer a solution in managed code, but if there isn’t one I can PInvoke.

Edit: Passing the PID seems like a more robust solution, but for curiosity’s sake, what if the child process was not my code but some exe that I have no control over? Is there a way to safeguard against possibly creating orphaned child processes?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T07:53:49+00:00Added an answer on May 11, 2026 at 7:53 am

    If the child process is your own code, you could pass it the PID of the parent process when you launch it. The child process could then fetch the process with Process.GetProcessById and subscribe to its Exited event with a handler which shuts down the rest of the (child) process gracefully. Note that you need to set the EnableRaisingEvents property on the process to true.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My program basically runs a executable file with command line arguments. A child process
Hi I have a program that requires a child process to modify a link
Ok i want to print the return status of my child process once it
Basically I have Host and Child program. I do not have sources for Child
I have a program that uses fork() to create a child process. I have
Basically I want to refresh a child form when focus is changed on parent
Basically I want a relative element to hide its absolute child on the z
I'm trying to create a function that searches up a WebControl's parent-child relationship (basically
Basically I want to check the extended permissions the user has granted my app.
Basically I want to convert a virtual path to an absolute path.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.