当nohup遇到console.ReadKey()

2019-04-28  本文已影响0人  ying1979

写了一个小程序,程序以console.ReadKey()结尾,目的是不让程序退出。在linux终端上这样执行是ok的。

dotnet xxx.dll

然后我需要他在我退出终端后继续执行。这样执行

nohup dotnet xxx.dll &

结果 出来Aborted。

百思不得其解。

折腾了两天,后来看nohup.out。

Unhandled Exception: System.InvalidOperationException: Cannot read keys when either application does not have a console or when console input has been redirected. Try Console.Read.

原来没有终端或者终端被限制。

换了个写法。

while (true){

}

可以了。

上一篇 下一篇

猜你喜欢

热点阅读