【发布时间】:2017-12-11 10:09:13
【问题描述】:
我有一个简单而有趣的问题。
我需要从 C# 应用程序启动一个进程(node.js 服务器)。
我找到了一段代码,解释了如何从应用程序中启动服务器。
Process p = new Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.FileName = @"c:\node\node.exe";**//Path to node installed folder****
string argument = "\\ bundle\main.js";
p.StartInfo.Arguments = @argument;
p.Start();
我的问题是:如果父进程(C# 应用程序)崩溃,这个进程会发生什么?子进程会退出/崩溃还是会继续运行,因为它是一个完全独立的程序?
在它继续运行的情况下,有没有办法“链接”这两个进程以确保在父进程崩溃时子进程退出?
【问题讨论】:
标签: c# server multiple-processes