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 8895537
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:48:22+00:00 2026-06-14T23:48:22+00:00

I seem to have created an immortal process with the following piece of code:

  • 0

I seem to have created an “immortal” process with the following piece of code:

System.Diagnostics.ProcessStartInfo test = new ProcessStartInfo("cmd", " /c " + aCommandLine); //aCommandLine is : ruby test.rb
test.CreateNoWindow = true;
test.RedirectStandardError = true;
test.RedirectStandardOutput = true;
test.UseShellExecute = false;
test.WorkingDirectory = System.IO.Path.GetDirectoryName(aRTextFilePath);
System.Diagnostics.Process aProcess = Process.Start(test);
aProcess.EnableRaisingEvents = true;
aProcess.Exited += new EventHandler(aProcess_Exited);
try
{
    //read synchronously to get the port number
    string aPortInformationLine = aProcess.StandardOutput.ReadLine();
    if (!aProcess.HasExited)
    {
        aProcess.Kill();
        Debug.Print("Process Has Exited");
    }
    //return true;
    errorOut = String.Format("Could not start process with command line : {0} from .rtext file {1}", aCommandLine, aRTextFilePath);
    port = -1;
    return false;
}
catch (Win32Exception ex)
{
    Debug.WriteLine(ex.NativeErrorCode.ToString());
    errorOut = String.Format("Could not start process with command line : {0} from .rtext file {1}. Error : {2}", aCommandLine, aRTextFilePath, ex.NativeErrorCode.ToString());
}
catch (Exception ex)
{
    Debug.WriteLine(ex.Message);
    errorOut = String.Format("Could not start process with command line : {0} from .rtext file {1}. Error : {2}", aCommandLine, aRTextFilePath, ex.Message);
}

So I am using cmd to start a ruby server of some sort. The process starts, and I am able to read output from the newly created process. However when the kill command is executed , no exceptions are thrown but the ruby process doesn’t die.

Does this have anything to do with using the cmd ? Am I doing something else wrong? Thanks

Edit:

I used process explorer and took 2 pics before and after the kill:

Before:

BeforeKill
After:

AfterKill

So while cmd.exe dies , ruby somehow manages to go on and live to see another day..

Edit2:

Answer to my problem: Kill process tree programmatically in C#

  • 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. Editorial Team
    Editorial Team
    2026-06-14T23:48:24+00:00Added an answer on June 14, 2026 at 11:48 pm

    Your hope that killing the command processor will also kill any process started by it is an idle one, Windows just doesn’t work that way. There is a mechanism for it in Windows, job objects, but you don’t want to go there. Simply don’t use cmd.exe, it doesn’t add any value. Start ruby.exe directly.

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

Sidebar

Related Questions

I have created a new repository in code.google.com , generated the code.google.com password and
I seem to have accidentally created Visual Studio 2010 tab groups which means that
I have created some code to popup a confirm dialog if a user tries
I seem to have got a little a head of myself. I have created
All the tables in the database created by a rails application seem to have
I have created a table with parallelism degree 2, however it doesn't seem like
I have created a program that has a JScrollPane . However, JScrollPane doesn't seem
I have created and initialized a git repo on a new turnkey version control
I have created a new iPhone project in Xcode 4 and added some files
I have created test application to test, Is StringBuilder copy data to another instance

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.