简体   繁体   中英

How to keep app open after bash command started C#

I have a problem with my code on linux. How do I keep app open after some bash commands are launched? This code:

Process.Start("/bin/bash", " -c 'screen -S testScreen -d -m bash -c  \"/home/test/Launcher.exe\"'");
Console.ReadKey();

What it does? it runs "Launcher.exe" in "testScreen", but for some reason, it closes program where that bit of code is there. I have there Console.ReadKey() in purpose and don't want to close it. Can someone explain me why does it close?

The Proces.Start method returns an object of type Process . After starting the bash command you can invoke WaitForExit on it.

var proc = Process.Start(...);
proc.WaitForExit();
Console.ReadKey();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM