简体   繁体   English

由于使用nohup,“Bad File Descriptor”异常

[英]“Bad File Descriptor” exception because of using nohup

My application can be launched via Terminal in linux OS as shell executable file. 我的应用程序可以通过Linux OS中的终端作为shell可执行文件启动。 I have no issues while executing it normally, however when i execute it along with 'nohup' command , it logs below exception in 'nohup.out' file 我正常执行它时没有问题,但是当我和'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
`

Now, as per my analysis, my application is based on spring shell and it tries to open/access the Terminal/Console initially while executing the application. 现在,根据我的分析,我的应用程序基于spring shell,它尝试在执行应用程序时最初打开/访问终端/控制台。 But as nohup is used , standard input is redirected from /dev/null and hence my application tries to open/access /dev/null as Terminal and hence i get above exception. 但是当使用nohup时,标准输入从/ dev / null重定向,因此我的应用程序尝试打开/访问/ dev / null作为终端,因此我得到了异常。

Please can someone point me whether i am going in correct direction or not? 请有人指出我是否朝着正确的方向前进? and also is there any alternative for nohup command? nohup命令还有其他选择吗?

你可以尝试这样的事情:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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