Setup: Ubuntu 12.04, 32 Bit; Scala 2.9.1; Java 1.6.0_24
Description:
While on the bash command line the command /usr/bin/timeout 10 scala -version
works fine, it gets stuck when executed within a bash script.
Executing on command line (duration < 1
seconds):
user@ubuntu:~$ /usr/bin/timeout 10 scala -version
Scala code runner version 2.9.1 -- Copyright 2002-2011, LAMP/EPFL
user@ubuntu:~$ echo $?
1
The very same command put in a bash script got stuck:
testScript.sh
:
#!/bin/bash
/usr/bin/timeout 10 scala -version
echo "finished with $?"
Executing testScript.sh
(duration 10 seconds):
user@ubuntu:~/scripts$ ./testScript.sh
Scala code runner version 2.9.1 -- Copyright 2002-2011, LAMP/EPFL
finished with 124
user@ubuntu:~/scripts$
Note: The problem does not appear with Java (which is used by Scala), it seems to be a Scala specific problem.
Question: Why does the timeout
call in the script got stuck ?
How can I fix this / What would be a good workaround ?