Browse Source

PRISM startup scripts: use exec call to start Java by default

Previously, we have called java as a child process of the startup
script. This is a bit problematic, as killing the startup script (in a
non-interactive setting, e.g., by running via a script that enforces a
time limit or killing it via a process manager) does not necessarily kill the
Java child process. This can leave potentially long-running Java processes
consuming resources floating around.

We avoid this by using 'exec java ...' to invoke Java, which replaces
the shell process with the Java process for PRISM, keeping the process
ID.

As a fallback, if it turns out there a unforseen problems with the new
exec-based approach, one can set the environment variable
PRISM_NO_EXEC to 'yes' to obtain the old behaviour, i.e.,

export PRISM_NO_EXEC=yes
bin/prism ...
accumulation-v4.7
Joachim Klein 7 years ago
parent
commit
615d3c2147
  1. 15
      prism/src/bin/prism.cygwin
  2. 14
      prism/src/bin/prism.darwin32
  3. 14
      prism/src/bin/prism.darwin64
  4. 14
      prism/src/bin/prism.linux

15
prism/src/bin/prism.cygwin

@ -107,5 +107,16 @@ if [ "$PRISM_DEBUG" != "" ]; then
PRISM_JAVA="$PRISM_DEBUG" PRISM_JAVA="$PRISM_DEBUG"
fi fi
# Run PRISM through Java
"$PRISM_JAVA" $PRISM_JAVA_ARG1 $PRISM_JAVA_ARG2 $PRISM_JAVA_DEBUG $PRISM_JAVAMAXMEM $PRISM_JAVASTACKSIZE -Djava.awt.headless=$PRISM_HEADLESS -Djava.library.path="$JAVA_LIBRARY_PATH_WIN" -classpath "$PRISM_CLASSPATH_WIN" $PRISM_MAINCLASS "$@"
#
# If environment variable PRISM_NO_EXEC is set to 'yes', use old method of starting Java.
# The default method is to use an exec call.
#
if [ "$PRISM_NO_EXEC" = "yes" ]; then
# Run PRISM through Java as a child process (exit code of script is exit code of the java call)
# Note: Killing this startup script will not necessarily kill the Java process
"$PRISM_JAVA" $PRISM_JAVA_ARG1 $PRISM_JAVA_ARG2 $PRISM_JAVA_DEBUG $PRISM_JAVAMAXMEM $PRISM_JAVASTACKSIZE -Djava.awt.headless=$PRISM_HEADLESS -Djava.library.path="$JAVA_LIBRARY_PATH_WIN" -classpath "$PRISM_CLASSPATH_WIN" $PRISM_MAINCLASS "$@"
else
# (Default) Run PRISM through Java via an exec call (the shell process is replaced by the Java process)
exec "$PRISM_JAVA" $PRISM_JAVA_ARG1 $PRISM_JAVA_ARG2 $PRISM_JAVA_DEBUG $PRISM_JAVAMAXMEM $PRISM_JAVASTACKSIZE -Djava.awt.headless=$PRISM_HEADLESS -Djava.library.path="$JAVA_LIBRARY_PATH_WIN" -classpath "$PRISM_CLASSPATH_WIN" $PRISM_MAINCLASS "$@"
fi

14
prism/src/bin/prism.darwin32

@ -112,6 +112,16 @@ if [ "$PRISM_DEBUG" != "" ]; then
PRISM_JAVA="$PRISM_DEBUG" PRISM_JAVA="$PRISM_DEBUG"
fi fi
# Run PRISM through Java (exit code of script is exit code of the java call)
"$PRISM_JAVA" $PRISM_JAVA_ARG1 $PRISM_JAVA_ARG2 $PRISM_JAVA_DEBUG $PRISM_JAVAMAXMEM $PRISM_JAVASTACKSIZE "$PRISM_ICON" "$PRISM_DOCK_NAME" -Djava.awt.headless=$PRISM_HEADLESS -Djava.library.path="$JAVA_LIBRARY_PATH" -classpath "$PRISM_CLASSPATH" $PRISM_MAINCLASS "$@"
#
# If environment variable PRISM_NO_EXEC is set to 'yes', use old method of starting Java.
# The default method is to use an exec call.
#
if [ "$PRISM_NO_EXEC" = "yes" ]; then
# Run PRISM through Java as a child process (exit code of script is exit code of the java call)
# Note: Killing this startup script will not necessarily kill the Java process
"$PRISM_JAVA" $PRISM_JAVA_ARG1 $PRISM_JAVA_ARG2 $PRISM_JAVA_DEBUG $PRISM_JAVAMAXMEM $PRISM_JAVASTACKSIZE "$PRISM_ICON" "$PRISM_DOCK_NAME" -Djava.awt.headless=$PRISM_HEADLESS -Djava.library.path="$JAVA_LIBRARY_PATH" -classpath "$PRISM_CLASSPATH" $PRISM_MAINCLASS "$@"
else
# (Default) Run PRISM through Java via an exec call (the shell process is replaced by the Java process)
exec "$PRISM_JAVA" $PRISM_JAVA_ARG1 $PRISM_JAVA_ARG2 $PRISM_JAVA_DEBUG $PRISM_JAVAMAXMEM $PRISM_JAVASTACKSIZE "$PRISM_ICON" "$PRISM_DOCK_NAME" -Djava.awt.headless=$PRISM_HEADLESS -Djava.library.path="$JAVA_LIBRARY_PATH" -classpath "$PRISM_CLASSPATH" $PRISM_MAINCLASS "$@"
fi

14
prism/src/bin/prism.darwin64

@ -112,6 +112,16 @@ if [ "$PRISM_DEBUG" != "" ]; then
PRISM_JAVA="$PRISM_DEBUG" PRISM_JAVA="$PRISM_DEBUG"
fi fi
# Run PRISM through Java (exit code of script is exit code of the java call)
"$PRISM_JAVA" $PRISM_JAVA_ARG1 $PRISM_JAVA_ARG2 $PRISM_JAVA_DEBUG $PRISM_JAVAMAXMEM $PRISM_JAVASTACKSIZE "$PRISM_ICON" "$PRISM_DOCK_NAME" -Djava.awt.headless=$PRISM_HEADLESS -Djava.library.path="$JAVA_LIBRARY_PATH" -classpath "$PRISM_CLASSPATH" $PRISM_MAINCLASS "$@"
#
# If environment variable PRISM_NO_EXEC is set to 'yes', use old method of starting Java.
# The default method is to use an exec call.
#
if [ "$PRISM_NO_EXEC" = "yes" ]; then
# Run PRISM through Java as a child process (exit code of script is exit code of the java call)
# Note: Killing this startup script will not necessarily kill the Java process
"$PRISM_JAVA" $PRISM_JAVA_ARG1 $PRISM_JAVA_ARG2 $PRISM_JAVA_DEBUG $PRISM_JAVAMAXMEM $PRISM_JAVASTACKSIZE "$PRISM_ICON" "$PRISM_DOCK_NAME" -Djava.awt.headless=$PRISM_HEADLESS -Djava.library.path="$JAVA_LIBRARY_PATH" -classpath "$PRISM_CLASSPATH" $PRISM_MAINCLASS "$@"
else
# (Default) Run PRISM through Java via an exec call (the shell process is replaced by the Java process)
exec "$PRISM_JAVA" $PRISM_JAVA_ARG1 $PRISM_JAVA_ARG2 $PRISM_JAVA_DEBUG $PRISM_JAVAMAXMEM $PRISM_JAVASTACKSIZE "$PRISM_ICON" "$PRISM_DOCK_NAME" -Djava.awt.headless=$PRISM_HEADLESS -Djava.library.path="$JAVA_LIBRARY_PATH" -classpath "$PRISM_CLASSPATH" $PRISM_MAINCLASS "$@"
fi

14
prism/src/bin/prism.linux

@ -103,6 +103,16 @@ if [ "$PRISM_DEBUG" != "" ]; then
PRISM_JAVA="$PRISM_DEBUG" PRISM_JAVA="$PRISM_DEBUG"
fi fi
# Run PRISM through Java (exit code of script is exit code of the java call)
"$PRISM_JAVA" $PRISM_JAVA_ARG1 $PRISM_JAVA_ARG2 $PRISM_JAVA_DEBUG $PRISM_JAVAMAXMEM $PRISM_JAVASTACKSIZE -Djava.awt.headless=$PRISM_HEADLESS -Djava.library.path="$JAVA_LIBRARY_PATH" -classpath "$PRISM_CLASSPATH" $PRISM_MAINCLASS "$@"
#
# If environment variable PRISM_NO_EXEC is set to 'yes', use old method of starting Java.
# The default method is to use an exec call.
#
if [ "$PRISM_NO_EXEC" = "yes" ]; then
# Run PRISM through Java as a child process (exit code of script is exit code of the java call)
# Note: Killing this startup script will not necessarily kill the Java process
"$PRISM_JAVA" $PRISM_JAVA_ARG1 $PRISM_JAVA_ARG2 $PRISM_JAVA_DEBUG $PRISM_JAVAMAXMEM $PRISM_JAVASTACKSIZE -Djava.awt.headless=$PRISM_HEADLESS -Djava.library.path="$JAVA_LIBRARY_PATH" -classpath "$PRISM_CLASSPATH" $PRISM_MAINCLASS "$@"
else
# (Default) Run PRISM through Java via an exec call (the shell process is replaced by the Java process)
exec "$PRISM_JAVA" $PRISM_JAVA_ARG1 $PRISM_JAVA_ARG2 $PRISM_JAVA_DEBUG $PRISM_JAVAMAXMEM $PRISM_JAVASTACKSIZE -Djava.awt.headless=$PRISM_HEADLESS -Djava.library.path="$JAVA_LIBRARY_PATH" -classpath "$PRISM_CLASSPATH" $PRISM_MAINCLASS "$@"
fi
Loading…
Cancel
Save