【问题标题】:"Bad File Descriptor" exception because of using nohup由于使用 nohup 导致的“错误文件描述符”异常
【发布时间】:2016-10-17 21:21:04
【问题描述】:

我的应用程序可以通过 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 命令的替代方法吗?

【问题讨论】:

    标签: linux terminal nohup jline spring-shell


    【解决方案1】:

    你可以试试这样的:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-12
      • 2012-02-10
      • 2020-09-27
      • 2021-01-05
      • 2011-09-08
      相关资源
      最近更新 更多