Looks like sbt
requested input from your terminal. If it does not really need input (which is probably the case when you run program in background), you can run it like this:
sbt run </dev/null >output-file &
See this answer for details.
EDIT
Ok, now that was a puzzle. Short answer: run sbt
as follows:
setsid nohup sbt run &
Rationale:
The reason why sbt
stops is arrival of SIGTTOU
signal. It is delivered to background process in several cases, which include modifying terminal configuration. This is our case because according to strace -f sbt run &
, sbt
does a lot of black magic under the hood like this:
[pid 16600] execve("/usr/bin/sh", ["sh", "-c", "stty -g < /dev/tty"], [/* 75 vars */] <unfinished ...>
To work this around, you can run sbt
in a different session to detach it from current terminal, so that it won't open /dev/tty and mess with our terminal.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…