gpt4 book ai didi

linux - "Bad File Descriptor"异常因为使用nohup

转载 作者:IT王子 更新时间:2023-10-29 00:44:02 25 4
gpt4 key购买 nike

我的应用程序可以通过 linux 操作系统中的终端作为 shell 可执行文件启动。我正常执行它时没有问题,但是当我将它与“nohup”命令一起执行时,它会在“nohup.out”中记录以下异常文件

`Exception in thread "Spring Shell" java.lang.IllegalStateException: Shell line reading failure
at org.springframework.shell.core.JLineShell.promptLoop(JLineShell.java:541)
at org.springframework.shell.core.JLineShell.run(JLineShell.java:179)
at java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: Ungültiger Dateideskriptor  this is in english “Invalid File Descriptor”
at java.io.FileInputStream.read(Native Method)
at jline.internal.NonBlockingInputStream.read(NonBlockingInputStream.java:169)
at jline.internal.NonBlockingInputStream.read(NonBlockingInputStream.java:137)
at jline.internal.NonBlockingInputStream.read(NonBlockingInputStream.java:246)
at jline.internal.InputStreamReader.read(InputStreamReader.java:261)
at jline.internal.InputStreamReader.read(InputStreamReader.java:198)
at jline.console.ConsoleReader.readCharacter(ConsoleReader.java:2038)
at jline.console.ConsoleReader.readLine(ConsoleReader.java:2242)
at jline.console.ConsoleReader.readLine(ConsoleReader.java:2162)
at jline.console.ConsoleReader.readLine(ConsoleReader.java:2150)
at org.springframework.shell.core.JLineShell.promptLoop(JLineShell.java:522)
... 2 more
`

现在,根据我的分析,我的应用程序是基于 spring shell 的,它会在执行应用程序时尝试打开/访问终端/控制台。但是由于使用了 nohup,标准输入从/dev/null 重定向,因此我的应用程序尝试打开/访问/dev/null 作为终端,因此我遇到了上述异常。

有人能指出我的方向是否正确吗?nohup 命令还有其他选择吗?

最佳答案

你可以尝试这样的事情:

nohup java -jar shell-app.jar 'spring shell command' > log.log 2>&1

关于linux - "Bad File Descriptor"异常因为使用nohup,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37857815/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com