Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #16441

Re: Does bash save/restore terminal settings as required by POSIX job control?

Path csiph.com!xmission!news.snarked.org!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail
From Godmar Back <godmar@gmail.com>
Newsgroups gnu.bash.bug
Subject Re: Does bash save/restore terminal settings as required by POSIX job control?
Date Mon, 22 Jun 2020 21:26:02 -0400
Lines 70
Approved bug-bash@gnu.org
Message-ID <mailman.313.1592875579.2574.bug-bash@gnu.org> (permalink)
References <CAB4+JYKZjPPYaNmhLZCDMUhvj9nEfLbaNgX3Q0c+hDHPC2mAew@mail.gmail.com> <fe98cc42-4613-8f30-10c5-66d95a49a6e2@case.edu> <CAB4+JY+rNKGjt-7TKmkHUfnSEU=s92m89ZWjunyaTyouMMe3fA@mail.gmail.com> <47f62134-eab7-b5e3-3448-2b7bb9c93444@case.edu> <CAB4+JYLkTjWgGBBt=D73Pq2dR9_LVYGdRNhQ3hyzXYSQNnM8XQ@mail.gmail.com>
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type text/plain; charset="UTF-8"
X-Trace usenet.stanford.edu 1592875580 597 209.51.188.17 (23 Jun 2020 01:26:20 GMT)
X-Complaints-To action@cs.stanford.edu
Cc bug-bash@gnu.org
To Chester Ramey <chet.ramey@case.edu>
Envelope-to bug-bash@gnu.org
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=+XBFN1iw/LXRj3qnmXOD0TaY0OmsrwnsO+3DVzLrgeM=; b=gsaYlU9mDvsJLN7nKUSV4Xws85dcbE8iVMPux43+TDKeWi3aeSYwiOCL0lMESfRaNK zjY86+ONeBFvmZpba7kaXMOfD8I4tHGbONoBqFLWqc2NcFBUXlZ+YpBfOt+bzSWShXNC sSbRV4tmfIhORho88sO+4iHa44GqOwHtGJvc1NZDDd584VO//DG5wl48cjuWBKimNNl6 mG9zak1muWR14qvrPOCzuqgqzo+2i25oMxE7REWYiZRPkdPjG3RBB0JMdsCfisOzUH40 U8lFpCUj94KrrGInU01QmIkTQyPULiCgDu7Bi5gKV7vDEf/ICKE6oC/30G+NdTr1o4qs ap7Q==
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=+XBFN1iw/LXRj3qnmXOD0TaY0OmsrwnsO+3DVzLrgeM=; b=b8rDAGvyX4t3VQsiCgnldfjU5qiwCMCl0dkmMLqRco/pgoU5NIJb8Dxvcf5s+dNxoX YBlaI3+xn1cLgI5Zq/EnNnq9mVpQ3Xzs9819QMNITvsCMUMvkOYQIo65VhLDdHWk4xJ1 Rz1xPOdvTnELDQkNuqXN1bpT1xuEpNyeazGmxUTBn9DCRp7SV6hSydMaZbDS1hANUTbK TdFFceGj2wf3CK4AfdDmbkYMUpunvnTx7W13gAFW0HFzzi10XvplSmMxd0pRqMRrExrk wBI/G1o6VUTOzMK+//XZphQ167CatRN23CmGua9UPvqhGzNq1WbTsFDFI60JC5XfVj1E PYfg==
X-Gm-Message-State AOAM530i46/5ZeVhLjol2ASXaVnldAdpR9AYoQpvdN/rgNbLNOW0gQp9 CnfDD/NIQWuH4Uj7ihstSbinGn4UxigwKRF1cq8=
X-Google-Smtp-Source ABdhPJzS16ngOPptbeFGQMwlqHvCOubP9G4OVxUALuYmCmmdFz629YiyuEkluPy72DmyTodVrGbQHngJiGFApRbjKAA=
X-Received by 2002:a7b:c3d0:: with SMTP id t16mr20398640wmj.117.1592875574246; Mon, 22 Jun 2020 18:26:14 -0700 (PDT)
In-Reply-To <47f62134-eab7-b5e3-3448-2b7bb9c93444@case.edu>
Received-SPF pass client-ip=2a00:1450:4864:20::32a; envelope-from=godmar@gmail.com; helo=mail-wm1-x32a.google.com
X-detected-operating-system by eggs.gnu.org: No matching host in p0f cache. That's all we know.
X-Spam_score_int -20
X-Spam_score -2.1
X-Spam_bar --
X-Spam_report (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN
X-Spam_action no action
X-BeenThere bug-bash@gnu.org
X-Mailman-Version 2.1.23
Precedence list
List-Id Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org>
List-Unsubscribe <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe>
List-Archive <https://lists.gnu.org/archive/html/bug-bash>
List-Post <mailto:bug-bash@gnu.org>
List-Help <mailto:bug-bash-request@gnu.org?subject=help>
List-Subscribe <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe>
X-Mailman-Original-Message-ID <CAB4+JYLkTjWgGBBt=D73Pq2dR9_LVYGdRNhQ3hyzXYSQNnM8XQ@mail.gmail.com>
X-Mailman-Original-References <CAB4+JYKZjPPYaNmhLZCDMUhvj9nEfLbaNgX3Q0c+hDHPC2mAew@mail.gmail.com> <fe98cc42-4613-8f30-10c5-66d95a49a6e2@case.edu> <CAB4+JY+rNKGjt-7TKmkHUfnSEU=s92m89ZWjunyaTyouMMe3fA@mail.gmail.com> <47f62134-eab7-b5e3-3448-2b7bb9c93444@case.edu>
Xref csiph.com gnu.bash.bug:16441

Show key headers only | View raw


On Mon, Jun 22, 2020 at 6:28 PM Chet Ramey <chet.ramey@case.edu> wrote:
>
> >
> > Thank you for your reply. Could you share any insights why bash
> > doesn't follow POSIX in this regard, like zsh, but unlike ksh, tcsh,
> > and dash/ash?
>
> ksh93u+ 2012-08-01 on RHEL 7 does do this.
>
> tcsh isn't a POSIX shell, so I admit I don't pay attention to it.
>
> I got curious, so I looked at what dash does -- a system call trace looks
> like it seems to `succeed' because it doesn't save or restore the terminal
> settings at all (dash-0.5.10.2). That presumably holds true for other ash-
> based shells, but I didn't check. It does leave them susceptible to
> programs that don't clean up the terminal when they're suspended or
> terminate abnormally.

You're correct, and actually, your observation applies to tcsh as
well. If I stty the change before resuming, it will not restore the
previous state.

I checked the CVS web of 4.3 BSD and it seems that early versions of
vi/more couldn't rely on it since the shell didn't do it - for
instance, Bill Joy's 4.3 BSD csh.c didn't do it.

Going back in history, let me quote a bit more; it seems that the
POSIX writers were acknowledging 4.2 BSD as an influence:

--
While the job control facilities supplied by POSIX.1 can, in theory,
support different types of interactive job control interfaces supplied
by different types of shells, there was historically one particular
interface that was most common when the standard was originally
developed (provided by BSD C Shell). This discussion describes that
interface as a means of illustrating how the POSIX.1 job control
facilities can be used.
--

they also refer to csh as an influence by writing "(For example, from
the C Shell, the user can execute the command, csh &.)" which refers
to how a shell should behave if it doesn't have control of its
controlling terminal upon startup, and later write
--
The intent in adding 4.2 BSD-style job control functionality was to
adopt the necessary 4.2 BSD programmatic interface with only minimal
changes to resolve syntactic or semantic conflicts with System V or to
close recognized security holes.
--

Lastly, here's a quote that makes me think that it was their intent to
allow applications to run under job control even if those applications
changed terminal settings and were job control unaware:

---
Implementing Job Control Applications

Most applications do not need to be aware of job control signals and
operations; the intuitively correct behavior happens by default.
--

In any event, this was very illuminating - though I have one last
question: why did you not implement it?

Were you unaware of what POSIX asks you to do, or did you consciously
decide against implementing it (perhaps because, apparently, there
is/was never an apparent need to do so?)

 - Godmar

Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread


Thread

Re: Does bash save/restore terminal settings as required by POSIX job control? Godmar Back <godmar@gmail.com> - 2020-06-22 21:26 -0400

csiph-web