[ptest-runner][PATCH] Fix inappropriate ioctl when detaching tty
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 a
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. On subsequent calls, if deattach fails,
according to man 4 tty
it is obviously not attached to a terminal and does not
need to detach itself.
Detach was not necessary, skip the error message.
Signed-off-by: Tero Kinnunen <tero.kinnunen@...>
---
utils.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/utils.c b/utils.c
index a8ba190..35ef551 100644
--- a/utils.c
+++ b/utils.c
@@ -444,7 +444,7 @@ run_ptests(struct ptest_list *head, const struct ptest_options opts,
break;
}
dirname(ptest_dir);
- if (ioctl(0, TIOCNOTTY) == -1) {
+ if (ioctl(0, TIOCNOTTY) == -1 && errno != ENOTTY) {
fprintf(fp, "ERROR: Unable to detach from controlling tty, %s\n", strerror(errno));
}
--
2.25.1
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 a
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. On subsequent calls, if deattach fails,
according to man 4 tty
it is obviously not attached to a terminal and does not
need to detach itself.
Detach was not necessary, skip the error message.
Signed-off-by: Tero Kinnunen <tero.kinnunen@...>
---
utils.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/utils.c b/utils.c
index a8ba190..35ef551 100644
--- a/utils.c
+++ b/utils.c
@@ -444,7 +444,7 @@ run_ptests(struct ptest_list *head, const struct ptest_options opts,
break;
}
dirname(ptest_dir);
- if (ioctl(0, TIOCNOTTY) == -1) {
+ if (ioctl(0, TIOCNOTTY) == -1 && errno != ENOTTY) {
fprintf(fp, "ERROR: Unable to detach from controlling tty, %s\n", strerror(errno));
}
--
2.25.1