play1 icon indicating copy to clipboard operation
play1 copied to clipboard

[1.4.5] `subprocess.Popen` in Python script might throw OS exception on large `java_cmd` values

Open shervinafshar opened this issue 6 years ago • 1 comments

There is an OS limitation on the size of command parameters in Linux (1/4 of stack size, explained here).

Wherever Play 1.4.5 is doing something like:

try:
        process = subprocess.Popen (java_cmd, env=os.environ)
        signal.signal(signal.SIGTERM, handle_sigterm)
        return_code = process.wait()
	signal.signal(signal.SIGINT, handle_sigint)
        if 0 != return_code:
            sys.exit(return_code)
    except OSError:
        print "Could not execute the java executable, please make sure the JAVA_HOME environment variable is set properly (the java executable should reside at JAVA_HOME/bin/java). "
        sys.exit(-1)

The exception messaging would end up being misleading. JAVA_HOME is just fine. java_cmd is too long and an exception is thrown.

More informative exceptions make things a bit better:

   except OSError as err:
        print("OS error: {0}".format(err))
        print "~ Could not execute the java executable, please make sure the JAVA_HOME environment variable is set properly (the java executable should reside at JAVA_HOME/bin/jav\
a). "
        print "~ "
        sys.exit(-1)

shervinafshar avatar Jun 19 '18 04:06 shervinafshar

Thank you for this, saved me tons of time with windows OS

tzachs avatar Feb 01 '23 13:02 tzachs