# HG changeset patch
# User jfp <jf.pieronne@laposte.net>
# Date 1685025678 -7200
#      Thu May 25 16:41:18 2023 +0200
# Node ID 0277cbe9d0fac799ad84842cae8925c01c67f2ab
# Parent  5b6f0875e77a193f7b5c059f4d8a1133987dda1b
Log creprc error after restoring persona

diff --git a/supervisord.py b/supervisord.py
--- a/supervisord.py
+++ b/supervisord.py
@@ -417,6 +417,7 @@
         # for the logical names SYS$LOGIN, SYS$LOGIN_DEVICE, and SYS$SCRATCH.
         # These logical names are available to the created process only when the
         # specified image is LOGINOUT, and when the PRC$M_NOUAF flag is not set.
+        error = None
         try:
             stsflg = (
                 prcdef.PRC_M_IMPERSONATE
@@ -443,14 +444,16 @@
                 )[1]
             )
         except OSError as e:
-            logger.warning(
-                f"Can' create process {self.process_name}, error {e}"
-            )
+            error = e
             self.process.state = ProcessStates.FATAL
             return
         finally:
             starlet.persona_assume(persona_previous_id)
             starlet.persona_delete(persona_id)
+            if error is not None:
+                logger.warning(
+                    f"Can' create process {self.process_name}, error {error}"
+            )
         lib.set_logical(
             self.process_name + b'_PID',
             hex(pid)[2:].upper(),