public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "carlos at redhat dot com" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs@sourceware.org
Subject: [Bug libc/28853] Problems with terminal control
Date: Wed, 02 Feb 2022 19:35:30 +0000	[thread overview]
Message-ID: <bug-28853-131-w3DzVd3zFd@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-28853-131@http.sourceware.org/bugzilla/>

https://sourceware.org/bugzilla/show_bug.cgi?id=28853

Carlos O'Donell <carlos at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |carlos at redhat dot com

--- Comment #4 from Carlos O'Donell <carlos at redhat dot com> ---
Dave,

Thanks for the bug report.

I can confirm that posix/tst-spawn6 breaks out of the support/* isolation and
in doing so impacts the shell / process group / session on the terminal.

e.g.
[2]+  Stopped                 less ~/build/glibc-review/check.log

(In reply to John David Anglin from comment #2)
> I suppose this is the problematic part of the change:
> 
>   /* Set the controlling terminal.  */
>   if ((attr->__flags & POSIX_SPAWN_TCSETPGROUP) != 0)
>     {
>       /* Check if it is possible to avoid an extra syscall.  */
>       pid_t pgrp = (attr->__flags & POSIX_SPAWN_SETPGROUP) != 0
>                     && attr->__pgrp != 0
>                    ? attr->__pgrp : __getpgid (0);
>       if (__tcsetpgrp (attr->__ctty_fd, pgrp) != 0)
>         goto fail;
>     }

This is not problematic per-se, since this is what you want to do for shell
control, but if the test isolation code doesn't stop this affecting your
current shell then that's a problem.

The posix/tst-spawn6 test is the *only* test in which we exercise process group
control testing, and so it may break the testing isolation we expect.

(In reply to John David Anglin from comment #3)
> The  function tcsetpgrp() makes the process group with process group ID
> pgrp the foreground process group on the  terminal  associated  to fd,
> which  must  be  the  controlling  terminal of the calling process, and
> still be associated  with  its  session.   Moreover,  pgrp  must  be a
> (nonempty)  process  group belonging to the same session as the calling
> process.
> If tcsetpgrp() is called by a member of a background process  group in
> its  session, and the calling process is not blocking or ignoring SIGT-
> TOU, a SIGTTOU signal is sent to all members of this background process
> group.

Yes, for the current /dev/tty (in the test), we make the posix_spawn'd
process the foreground process group for the session to verify the test works
correctly.

I can't easily containerize the test because we don't setup an alternative
TTY/session/pgrp in the container e.g. tests-container += tst-spawn6.

make[2]: Leaving directory '/home/carlos/src/glibc-review/posix'
FAIL: posix/tst-spawn6
original exit status 1
error: tst-spawn6.c:138: open64 ("/dev/tty", 0x0, 0600): No such file or
directory
error: 1 test failures
make[1]: Leaving directory '/home/carlos/src/glibc-review'

-- 
You are receiving this mail because:
You are on the CC list for the bug.

  parent reply	other threads:[~2022-02-02 19:35 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-02 16:37 [Bug libc/28853] New: " danglin at gcc dot gnu.org
2022-02-02 17:15 ` [Bug libc/28853] " schwab@linux-m68k.org
2022-02-02 18:04 ` danglin at gcc dot gnu.org
2022-02-02 18:08 ` danglin at gcc dot gnu.org
2022-02-02 19:35 ` carlos at redhat dot com [this message]
2022-02-02 19:35 ` [Bug libc/28853] tst-spawn6 changes current foreground process group (breaks test isolation) carlos at redhat dot com
2022-02-02 19:37 ` carlos at redhat dot com
2022-02-03  1:22 ` sam at gentoo dot org
2022-02-03  4:09 ` carlos at redhat dot com
2022-02-03 11:10 ` adhemerval.zanella at linaro dot org
2022-02-03 11:11 ` adhemerval.zanella at linaro dot org
2022-02-03 11:13 ` adhemerval.zanella at linaro dot org
2022-02-07 16:40 ` adhemerval.zanella at linaro dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-28853-131-w3DzVd3zFd@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=glibc-bugs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 read-only IMAP folder(s) and NNTP newsgroup(s).