I am trying to run a Jython script in the background. This is what the script looks like,
a_jython_script.py
for i in range(10000):
print i
When I try to run it in the background, it is stopped before it prints anything.
$ jython a_jython_script.py &
[1] 12325
$
[1]+ Stopped jython a_jython_script.py
Sending it to the foreground allows it to continue normally. jython was installed via brew. Taking a look at what the jython startup script is doing, I can just run the Java program and get the same results.
$ /Library/Java/JavaVirtualMachines/jdk1.8.0_212.jdk/Contents/Home/bin/java -Xmx512m -Xss2560k -classpath ../../../../../../usr/local/Cellar/jython/2.7.1/libexec/jython.jar:. -Dpython.home=../../../../../../usr/local/Cellar/jython/2.7.1/libexec -Dpython.executable=../../../../../../usr/local/Cellar/jython/2.7.1/libexec/bin/jython -Dpython.launcher.uname=darwin -Dpython.launcher.tty=true -Dfile.encoding=UTF-8 org.python.util.jython a_jython_script.py &
[1] 12623
$
[1]+ Stopped /Library/Java/JavaVirtualMachines/jdk1.8.0_212.jdk/Contents/Home/bin/java -Xmx512m -Xss2560k -classpath ../../../../../../usr/local/Cellar/jython/2.7.1/libexec/jython.jar:. -Dpython.home=../../../../../../usr/local/Cellar/jython/2.7.1/libexec -Dpython.executable=../../../../../../usr/local/Cellar/jython/2.7.1/libexec/bin/jython -Dpython.launcher.uname=darwin -Dpython.launcher.tty=true -Dfile.encoding=UTF-8 org.python.util.jython a_jython_script.py
$
Adding nohup
does not make a difference.
Java was installed with the Oracle installer. I see the same behavior in Terminal as well as iTerm2. I do not see the same issue under Linux.
Best Answer
I got the answer on github: https://github.com/jythontools/jython/issues/148
Solution is summarized below.
when running with
jython
,Invoking with
java
add-Dpython.launcher.tty=false