runfvp: ignore setpgid errors when spawned

Message ID 20220707084905.1914073-1-ross.burton@arm.com
State New
Headers show
Series runfvp: ignore setpgid errors when spawned | expand

Commit Message

Ross Burton July 7, 2022, 8:49 a.m. UTC
From: Bertrand Marquis <bertrand.marquis@arm.com>

When runfvp is spawned from an other process (for example except), it is
throwing a permission error.
To solve the problem, surround the call to setpgid with a try/except and
ignore the permission errors.

Signed-off-by: Bertrand Marquis <bertrand.marquis@arm.com>
---
 scripts/runfvp | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

Jon Mason July 11, 2022, 3:05 p.m. UTC | #1
On Thu, 7 Jul 2022 09:49:05 +0100, Ross Burton wrote:
> When runfvp is spawned from an other process (for example except), it is
> throwing a permission error.
> To solve the problem, surround the call to setpgid with a try/except and
> ignore the permission errors.

Applied, thanks!

[1/1] runfvp: ignore setpgid errors when spawned
      commit: a25192f51dac9401f617df0376334f5d65d967cf

Best regards,
Jon Mason July 11, 2022, 9:32 p.m. UTC | #2
On Thu, 7 Jul 2022 09:49:05 +0100, Ross Burton wrote:
> When runfvp is spawned from an other process (for example except), it is
> throwing a permission error.
> To solve the problem, surround the call to setpgid with a try/except and
> ignore the permission errors.

Applied, thanks!

[1/1] runfvp: ignore setpgid errors when spawned
      commit: 528d28f7f14c3c2045e3f628ae018587bc9141c1

Best regards,

Patch

diff --git a/scripts/runfvp b/scripts/runfvp
index 0ebf873e..7a3c239a 100755
--- a/scripts/runfvp
+++ b/scripts/runfvp
@@ -270,7 +270,12 @@  if __name__ == "__main__":
     try:
         # Set the process group so that it's possible to kill runfvp and
         # everything it spawns easily.
-        os.setpgid(0, 0)
+        # Ignore permission errors happening when spawned from an other process
+        # for example run from except
+        try:
+            os.setpgid(0, 0)
+        except PermissionError:
+            pass
         if sys.stdin.isatty():
             signal.signal(signal.SIGTTOU, signal.SIG_IGN)
             os.tcsetpgrp(sys.stdin.fileno(), os.getpgrp())