Description: Backport embedded noop change from 1.1.1
 Later releases read the proc title from /proc/self/cmdline but 1.1.1 just made
 setproctitle do nothing.
Origin: upstream, https://github.com/dvarrazzo/py-setproctitle/compare/ece30c0421df5c1afc0406576b9c2ced1927f85b...version-1.1.1
Author: Daniele Varrazzo <daniele.varrazzo@gmail.com>
Author: Stefano Rivera <stefanor@ubuntu.com>
Bug-Upstream: https://github.com/dvarrazzo/py-setproctitle/issues/9
Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/python-setproctitle/+bug/1538736

--- a/src/setproctitle.c
+++ b/src/setproctitle.c
@@ -156,6 +156,9 @@
     int argc;
     char **argv;
     Py_GetArgcArgv(&argc, &argv);
+    if (argc <= 0 || argv == NULL) {
+        return;
+    }
     argv = fix_argv(argc, argv);
     save_ps_display_args(argc, argv);
 
--- /dev/null
+++ b/tests/pyrun.c
@@ -0,0 +1,30 @@
+/*-------------------------------------------------------------------------
+ *
+ * pyrun.c
+ *    Stand-alone program to test with embedded Python.
+ *
+ *    Run a Python program read from stdin. In case of error return 1.
+ *
+ * Copyright (c) 2011 Daniele Varrazzo <daniele.varrazzo@gmail.com>
+ *
+ *-------------------------------------------------------------------------
+ */
+
+#include <Python.h>
+
+int
+main(int argc, char *argv[])
+{
+    int rv = 0;
+
+    Py_Initialize();
+
+    if (0 != PyRun_SimpleFile(stdin, "stdin")) {
+        rv = 1;
+    }
+
+    Py_Finalize();
+
+    return rv;
+}
+
--- a/tests/setproctitle_test.py
+++ b/tests/setproctitle_test.py
@@ -143,13 +143,38 @@
                 del os.environ['PYTHONPATH']
 
 
-    def run_script(self, script=None, args=None):
+    def test_embedded(self):
+        """Check the module doesn't explode with embedded Python.
+
+        Simulate the condition that made spt explode with mod_wsgi
+        (see issue #9). Probably due to the Python interpreter main()
+        not executed.
+        """
+        exe = os.environ.get('ROOT_PATH', '.') + '/tests/pyrun'
+        if not os.path.exists(exe):
+            raise Exception('test program not found: %s' % exe)
+
+        self.run_script(r"""
+            import setproctitle
+            setproctitle.setproctitle("Hello, embedded!")
+
+            import os
+            print os.getpid()
+            print os.popen("ps -o pid,command 2> /dev/null").read()
+            """,
+            executable=exe)
+
+
+    def run_script(self, script=None, args=None, executable=None):
         """run a script in a separate process.
 
         if the script completes successfully, return the concatenation of
         ``stdout`` and ``stderr``. else fail.
         """
-        cmdline = sys.executable
+        if executable is None:
+            executable = sys.executable
+
+        cmdline = executable
         if args:
             cmdline = cmdline + " " + args
 
