All of lore.kernel.org
 help / color / mirror / Atom feed
* [ptest-runner][PATCH] Fix inappropriate ioctl when detaching tty
@ 2020-07-07  7:21 Tero Kinnunen
  2020-07-07 13:49 ` Anibal Limon
  0 siblings, 1 reply; 4+ messages in thread
From: Tero Kinnunen @ 2020-07-07  7:21 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 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@vaisala.com>
---
 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


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

* Re: [ptest-runner][PATCH] Fix inappropriate ioctl when detaching tty
  2020-07-07  7:21 [ptest-runner][PATCH] Fix inappropriate ioctl when detaching tty Tero Kinnunen
@ 2020-07-07 13:49 ` Anibal Limon
  2020-07-08  6:46   ` Tero Kinnunen
  0 siblings, 1 reply; 4+ messages in thread
From: Anibal Limon @ 2020-07-07 13:49 UTC (permalink / raw)
  To: Tero Kinnunen; +Cc: Yocto discussion list

[-- Attachment #1: Type: text/plain, Size: 1606 bytes --]

Hi Tero,

First thanks for the patch, Is there an option to test for isatty(fd) for
run ioctl instead?.

Regards,
Anibal

On Tue, 7 Jul 2020 at 02:21, 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 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@vaisala.com>
> ---
>  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
>
>

[-- Attachment #2: Type: text/html, Size: 2237 bytes --]

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

* Re: [ptest-runner][PATCH] Fix inappropriate ioctl when detaching tty
  2020-07-07 13:49 ` Anibal Limon
@ 2020-07-08  6:46   ` Tero Kinnunen
  2020-07-09 14:21     ` [yocto] " Anibal Limon
  0 siblings, 1 reply; 4+ messages in thread
From: Tero Kinnunen @ 2020-07-08  6:46 UTC (permalink / raw)
  To: yocto

[-- Attachment #1: Type: text/plain, Size: 481 bytes --]

On Tue, Jul 7, 2020 at 06:49 AM, Anibal Limon wrote:

> 
> First thanks for the patch, Is there an option to test for isatty(fd) for
> run ioctl instead?.
> 

Hi Anibal,

if (isatty(0) && ioctl(0, TIOCNOTTY) == -1)

would help for ssh case but not to errors between tests. There fd 0 is a tty but detach should
be done only once. Now it is inside loop. It could work if it was also moved outside the loop,
before PTEST_LIST_ITERATE_START?

Kind regards,

- Tero

[-- Attachment #2: Type: text/html, Size: 640 bytes --]

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

* Re: [yocto] [ptest-runner][PATCH] Fix inappropriate ioctl when detaching tty
  2020-07-08  6:46   ` Tero Kinnunen
@ 2020-07-09 14:21     ` Anibal Limon
  0 siblings, 0 replies; 4+ messages in thread
From: Anibal Limon @ 2020-07-09 14:21 UTC (permalink / raw)
  To: Tero Kinnunen; +Cc: yocto

[-- Attachment #1: Type: text/plain, Size: 678 bytes --]

On Wed, 8 Jul 2020 at 01:46, Tero Kinnunen <tero.kinnunen@vaisala.com>
wrote:

> On Tue, Jul 7, 2020 at 06:49 AM, Anibal Limon wrote:
>
> First thanks for the patch, Is there an option to test for isatty(fd) for
> run ioctl instead?.
>
> Hi Anibal,
>
>     if (isatty(0) && ioctl(0, TIOCNOTTY) == -1)
>
> would help for ssh case but not to errors between tests. There fd 0 is a
> tty but detach should
> be done only once. Now it is inside loop. It could work if it was also
> moved outside the loop,
> before PTEST_LIST_ITERATE_START?
>

Agree, Add isatty(0) and move that validation outside the loop.

Anibal


>
> Kind regards,
>
>     - Tero 
>

[-- Attachment #2: Type: text/html, Size: 1263 bytes --]

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

end of thread, other threads:[~2020-07-09 14:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-07  7:21 [ptest-runner][PATCH] Fix inappropriate ioctl when detaching tty Tero Kinnunen
2020-07-07 13:49 ` Anibal Limon
2020-07-08  6:46   ` Tero Kinnunen
2020-07-09 14:21     ` [yocto] " Anibal Limon

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.