[ptest-runner,v2] Fix inappropriate ioctl when detaching tty

Submitted by Tero Kinnunen on July 10, 2020, 5:44 a.m. | Patch ID: 174371

Details

Message ID 20200710054432.557157-1-tero.kinnunen@vaisala.com
State New
Headers show

Commit Message

Tero Kinnunen July 10, 2020, 5:44 a.m.
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(-)

Patch hide | download patch | download mbox

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));

Comments

Aníbal Limón July 13, 2020, 7:29 p.m.
Applied, Thanks!.

Anibal

On Fri, 10 Jul 2020 at 00:44, Tero Kinnunen <tero.kinnunen@vaisala.com>
wrote:

> 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
>
>
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#49933): https://lists.yoctoproject.org/g/yocto/message/49933
Mute This Topic: https://lists.yoctoproject.org/mt/75413484/3617530
Group Owner: yocto+owner@lists.yoctoproject.org
Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub  [oe-patchwork@oe-patch.openembedded.org]
-=-=-=-=-=-=-=-=-=-=-=-