All of lore.kernel.org
 help / color / mirror / Atom feed
* [ptest-runner][PATCH v2] Fix inappropriate ioctl when detaching tty
@ 2020-07-10  5:44 Tero Kinnunen
  2020-07-13 19:29 ` Anibal Limon
  0 siblings, 1 reply; 7+ messages in thread
From: Tero Kinnunen @ 2020-07-10  5:44 UTC (permalink / raw)
  To: yocto; +Cc: anibal.limon, Tero Kinnunen

Fixes error

    ERROR: Unable to detach from controlling tty, Inappropriate ioctl for device

when running multiple ptests

    ptest-runner a b

or when invoked over ssh single command, like

    $ ssh localhost ptest-runner

For ssh case, fd 0 is not a tty. (isatty(0) is false).
When running multiple ptests, deattach for parent needs to be
done only once.

Signed-off-by: Tero Kinnunen <tero.kinnunen@vaisala.com>
---
 utils.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/utils.c b/utils.c
index a8ba190..a4e190e 100644
--- a/utils.c
+++ b/utils.c
@@ -437,6 +437,9 @@ run_ptests(struct ptest_list *head, const struct ptest_options opts,
 			break;
 		}
 		fprintf(fp, "START: %s\n", progname);
+		if (isatty(0) && ioctl(0, TIOCNOTTY) == -1) {
+			fprintf(fp, "ERROR: Unable to detach from controlling tty, %s\n", strerror(errno));
+		}
 		PTEST_LIST_ITERATE_START(head, p)
 			char *ptest_dir = strdup(p->run_ptest);
 			if (ptest_dir == NULL) {
@@ -444,9 +447,6 @@ run_ptests(struct ptest_list *head, const struct ptest_options opts,
 				break;
 			}
 			dirname(ptest_dir);
-			if (ioctl(0, TIOCNOTTY) == -1) {
-				fprintf(fp, "ERROR: Unable to detach from controlling tty, %s\n", strerror(errno));
-			}
 
 			if ((pgid = getpgid(0)) == -1) {
 				fprintf(fp, "ERROR: getpgid() failed, %s\n", strerror(errno));
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-02-19 17:34 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-10  5:44 [ptest-runner][PATCH v2] Fix inappropriate ioctl when detaching tty Tero Kinnunen
2020-07-13 19:29 ` Anibal Limon
2021-02-19  6:44   ` [yocto] " Chen Qi
2021-02-19 15:18     ` Randy MacLeod
2021-02-19 17:24       ` Anibal Limon
2021-02-19 17:25       ` Richard Purdie
2021-02-19 17:34         ` Randy MacLeod

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.