* [PATCH v2] runfvp: Ensure new process group is in the foreground
@ 2021-10-21 11:16 Ross Burton
2021-11-01 15:50 ` [meta-arm] " Peter Hoyes
0 siblings, 1 reply; 3+ messages in thread
From: Ross Burton @ 2021-10-21 11:16 UTC (permalink / raw)
To: meta-arm
From: Peter Hoyes <Peter.Hoyes@arm.com>
When a new process group is created, it is launched in the background
and any attempt to access the session terminal triggers a SIGTTIN (for
stdin) or SIGTTOU (for stdout) signal. These are ignored in an
interactive shell, but the default signal behavior in a new job is to
send a SIGTSTP to the whole process group. This causes runfvp to hang
when executed via a subprocess when stdin is accessed.
After creating a new process group, use tcsetpgrp to make the new group
the foreground process for the terminal associated with stdin/stdout,
but only if stdin is a tty.
The documentation for tcsetgrp states that tcsetpgrp itself raises a
SIGTTOU signal, so set this signal to SIG_IGN.
Signed-off-by: Peter Hoyes <Peter.Hoyes@arm.com>
Change-Id: I349a825df7fcb8a3cedb81762b901c6f50fa53b5
---
scripts/runfvp | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/scripts/runfvp b/scripts/runfvp
index 97836726..66a76cc5 100755
--- a/scripts/runfvp
+++ b/scripts/runfvp
@@ -4,6 +4,7 @@ import asyncio
import json
import os
import re
+import signal
import sys
import subprocess
import pathlib
@@ -220,6 +221,9 @@ if __name__ == "__main__":
# Set the process group so that it's possible to kill runfvp and
# everything it spawns easily.
os.setpgid(0, 0)
+ if sys.stdin.isatty():
+ signal.signal(signal.SIGTTOU, signal.SIG_IGN)
+ os.tcsetpgrp(sys.stdin.fileno(), os.getpgrp())
runfvp(sys.argv[1:])
except KeyboardInterrupt:
pass
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [meta-arm] [PATCH v2] runfvp: Ensure new process group is in the foreground
2021-10-21 11:16 [PATCH v2] runfvp: Ensure new process group is in the foreground Ross Burton
@ 2021-11-01 15:50 ` Peter Hoyes
2021-11-02 15:04 ` Jon Mason
0 siblings, 1 reply; 3+ messages in thread
From: Peter Hoyes @ 2021-11-01 15:50 UTC (permalink / raw)
To: meta-arm; +Cc: ross
[-- Attachment #1: Type: text/plain, Size: 2110 bytes --]
Hi,
I'm seeing the same issue on honister - is it possible to backport this patch?
Cheers,
Peter
________________________________
From: meta-arm@lists.yoctoproject.org <meta-arm@lists.yoctoproject.org> on behalf of Ross Burton via lists.yoctoproject.org <ross=burtonini.com@lists.yoctoproject.org>
Sent: 21 October 2021 12:16
To: meta-arm@lists.yoctoproject.org <meta-arm@lists.yoctoproject.org>
Subject: [meta-arm] [PATCH v2] runfvp: Ensure new process group is in the foreground
From: Peter Hoyes <Peter.Hoyes@arm.com>
When a new process group is created, it is launched in the background
and any attempt to access the session terminal triggers a SIGTTIN (for
stdin) or SIGTTOU (for stdout) signal. These are ignored in an
interactive shell, but the default signal behavior in a new job is to
send a SIGTSTP to the whole process group. This causes runfvp to hang
when executed via a subprocess when stdin is accessed.
After creating a new process group, use tcsetpgrp to make the new group
the foreground process for the terminal associated with stdin/stdout,
but only if stdin is a tty.
The documentation for tcsetgrp states that tcsetpgrp itself raises a
SIGTTOU signal, so set this signal to SIG_IGN.
Signed-off-by: Peter Hoyes <Peter.Hoyes@arm.com>
Change-Id: I349a825df7fcb8a3cedb81762b901c6f50fa53b5
---
scripts/runfvp | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/scripts/runfvp b/scripts/runfvp
index 97836726..66a76cc5 100755
--- a/scripts/runfvp
+++ b/scripts/runfvp
@@ -4,6 +4,7 @@ import asyncio
import json
import os
import re
+import signal
import sys
import subprocess
import pathlib
@@ -220,6 +221,9 @@ if __name__ == "__main__":
# Set the process group so that it's possible to kill runfvp and
# everything it spawns easily.
os.setpgid(0, 0)
+ if sys.stdin.isatty():
+ signal.signal(signal.SIGTTOU, signal.SIG_IGN)
+ os.tcsetpgrp(sys.stdin.fileno(), os.getpgrp())
runfvp(sys.argv[1:])
except KeyboardInterrupt:
pass
--
2.25.1
[-- Attachment #2: Type: text/html, Size: 4015 bytes --]
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [meta-arm] [PATCH v2] runfvp: Ensure new process group is in the foreground
2021-11-01 15:50 ` [meta-arm] " Peter Hoyes
@ 2021-11-02 15:04 ` Jon Mason
0 siblings, 0 replies; 3+ messages in thread
From: Jon Mason @ 2021-11-02 15:04 UTC (permalink / raw)
To: Peter Hoyes; +Cc: meta-arm, ross
On Mon, Nov 01, 2021 at 03:50:15PM +0000, Peter Hoyes wrote:
> Hi,
>
> I'm seeing the same issue on honister - is it possible to backport this patch?
Done
>
> Cheers,
> Peter
>
> ________________________________
> From: meta-arm@lists.yoctoproject.org <meta-arm@lists.yoctoproject.org> on behalf of Ross Burton via lists.yoctoproject.org <ross=burtonini.com@lists.yoctoproject.org>
> Sent: 21 October 2021 12:16
> To: meta-arm@lists.yoctoproject.org <meta-arm@lists.yoctoproject.org>
> Subject: [meta-arm] [PATCH v2] runfvp: Ensure new process group is in the foreground
>
> From: Peter Hoyes <Peter.Hoyes@arm.com>
>
> When a new process group is created, it is launched in the background
> and any attempt to access the session terminal triggers a SIGTTIN (for
> stdin) or SIGTTOU (for stdout) signal. These are ignored in an
> interactive shell, but the default signal behavior in a new job is to
> send a SIGTSTP to the whole process group. This causes runfvp to hang
> when executed via a subprocess when stdin is accessed.
>
> After creating a new process group, use tcsetpgrp to make the new group
> the foreground process for the terminal associated with stdin/stdout,
> but only if stdin is a tty.
>
> The documentation for tcsetgrp states that tcsetpgrp itself raises a
> SIGTTOU signal, so set this signal to SIG_IGN.
>
> Signed-off-by: Peter Hoyes <Peter.Hoyes@arm.com>
> Change-Id: I349a825df7fcb8a3cedb81762b901c6f50fa53b5
> ---
> scripts/runfvp | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/scripts/runfvp b/scripts/runfvp
> index 97836726..66a76cc5 100755
> --- a/scripts/runfvp
> +++ b/scripts/runfvp
> @@ -4,6 +4,7 @@ import asyncio
> import json
> import os
> import re
> +import signal
> import sys
> import subprocess
> import pathlib
> @@ -220,6 +221,9 @@ if __name__ == "__main__":
> # Set the process group so that it's possible to kill runfvp and
> # everything it spawns easily.
> os.setpgid(0, 0)
> + if sys.stdin.isatty():
> + signal.signal(signal.SIGTTOU, signal.SIG_IGN)
> + os.tcsetpgrp(sys.stdin.fileno(), os.getpgrp())
> runfvp(sys.argv[1:])
> except KeyboardInterrupt:
> pass
> --
> 2.25.1
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#2328): https://lists.yoctoproject.org/g/meta-arm/message/2328
> Mute This Topic: https://lists.yoctoproject.org/mt/86487012/3616920
> Group Owner: meta-arm+owner@lists.yoctoproject.org
> Unsubscribe: https://lists.yoctoproject.org/g/meta-arm/unsub [jdmason@kudzu.us]
> -=-=-=-=-=-=-=-=-=-=-=-
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-11-02 15:04 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-21 11:16 [PATCH v2] runfvp: Ensure new process group is in the foreground Ross Burton
2021-11-01 15:50 ` [meta-arm] " Peter Hoyes
2021-11-02 15:04 ` Jon Mason
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).