public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/28853] New: Problems with terminal control
@ 2022-02-02 16:37 danglin at gcc dot gnu.org
  2022-02-02 17:15 ` [Bug libc/28853] " schwab@linux-m68k.org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: danglin at gcc dot gnu.org @ 2022-02-02 16:37 UTC (permalink / raw)
  To: glibc-bugs

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

            Bug ID: 28853
           Summary: Problems with terminal control
           Product: glibc
           Version: 2.35
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
          Assignee: unassigned at sourceware dot org
          Reporter: danglin at gcc dot gnu.org
                CC: adhemerval.zanella at linaro dot org, deller at gmx dot de,
                    drepper.fsp at gmail dot com
  Target Milestone: ---
              Host: hppa*-*-linux*
            Target: hppa*-*-linux*
             Build: hppa*-*-linux*

This commit causes issues with job control on hppa:

commit 342cc934a3bf74ac618e2318d738f22ac93257ba (HEAD)
Author:     Adhemerval Zanella <adhemerval.zanella@linaro.org>
AuthorDate: Mon Jun 14 14:41:31 2021 -0300
Commit:     Adhemerval Zanella <adhemerval.zanella@linaro.org>
CommitDate: Tue Jan 25 14:07:53 2022 -0300

    posix: Add terminal control setting support for posix_spawn

    Currently there is no proper way to set the controlling terminal through
    posix_spawn in race free manner [1].  This forces shell implementations
    to keep using fork+exec when launching background process groups,
    even when using posix_spawn yields better performance.

    This patch adds a new GNU extension so the creating process can
    configure the created process terminal group.  This is done with a new
    flag, POSIX_SPAWN_TCSETPGROUP, along with two new attribute functions:
    posix_spawnattr_tcsetpgrp_np, and posix_spawnattr_tcgetpgrp_np.
    The function sets a new attribute, spawn-tcgroupfd, that references to
    the controlling terminal.

    The controlling terminal is set after the spawn-pgroup attribute, and
    uses the spawn-tcgroupfd along with current creating process group
    (so it is composable with POSIX_SPAWN_SETPGROUP).

    To create a process and set the controlling terminal, one can use the
    following sequence:

        posix_spawnattr_t attr;
        posix_spawnattr_init (&attr);
        posix_spawnattr_setflags (&attr, POSIX_SPAWN_TCSETPGROUP);
        posix_spawnattr_tcsetpgrp_np (&attr, tcfd);

    If the idea is also to create a new process groups:

        posix_spawnattr_t attr;
        posix_spawnattr_init (&attr);
        posix_spawnattr_setflags (&attr, POSIX_SPAWN_TCSETPGROUP
                                         | POSIX_SPAWN_SETPGROUP);
        posix_spawnattr_tcsetpgrp_np (&attr, tcfd);
        posix_spawnattr_setpgroup (&attr, 0);

    The controlling terminal file descriptor is ignored if the new flag is
    not set.

    This interface is slight different than the one provided by QNX [2],
    which only provides the POSIX_SPAWN_TCSETPGROUP flag.  The QNX
    documentation does not specify how the controlling terminal is obtained
    nor how it iteracts with POSIX_SPAWN_SETPGROUP.  Since a glibc
    implementation is library based, it is more straightforward and avoid
    requires additional file descriptor operations to request the caller
    to setup the controlling terminal file descriptor (and it also allows
    a bit less error handling by posix_spawn).

    Checked on x86_64-linux-gnu and i686-linux-gnu.

    [1] https://github.com/ksh93/ksh/issues/79
    [2]
https://www.qnx.com/developers/docs/7.0.0/index.html#com.qnx.doc.neutrino.lib_ref/topic/p/posix_spawn.html

    Reviewed-by: Carlos O'Donell <carlos@redhat.com>
    Tested-by: Carlos O'Donell <carlos@redhat.com>

When I do a glibc build and check, I use a script as follows:

nohup ../build > build.log 2>&1 &

I usually monitor progress with less:

less build.log

At some point in the check, less stops and goes into the background.  I
think this occurs when tst-spawn6 runs.  It appears that the test affects
processes beyond those spawned in test.

This occurs with all kernel versions that I have tried.

With 5.16.4, I also see general problems with job control after running
the glibc testsuite.  Here is output from ssh login:

Using username "dave".
Authenticating with public key "imported-openssh-key"
Linux mx3210 5.16.4+ #1 SMP Sat Jan 29 18:56:52 UTC 2022 parisc64

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
You have no mail.
Last login: Sat Jan 29 20:27:13 2022 from 192.168.2.49
-bash: cannot set terminal process group (-1): Bad file descriptor
-bash: no job control in this shell

This doesn't seem to occur if glibc testsuite hasn't been run.

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

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

end of thread, other threads:[~2022-02-07 16:40 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-02 16:37 [Bug libc/28853] New: Problems with terminal control 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
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

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