Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/bin/sh Document that a N>&N (or N<&N) redirection turns off ...



details:   https://anonhg.NetBSD.org/src/rev/da7d802f3326
branches:  trunk
changeset: 345203:da7d802f3326
user:      kre <kre%NetBSD.org@localhost>
date:      Thu May 12 13:15:43 2016 +0000

description:
Document that a N>&N (or N<&N) redirection turns off close-on-exec for N
(where N is a decimal fd number) either when used as
        some-command N>&N
(where fd N is passed, open, to some-command - which is obviously what is
wanted)

Or as
        exec N>&N
which effects fd N for all future commands.

Note that this means
        exec N>foo N>&N
returns to the old behaviour of leaving the file descriptor open
when commands are run (as do most shells, other than ksh) and works for
both new and old NetBSD shells (old ones never set close-on-exec, and treat
N>&N as a rather meaingless no-op request, and just ignore it), new ones
set close-on-exec on the first redirection, then disable it again on the
second.

Everything here about >& for output fds applies to <& for input ones.

OK christos@

diffstat:

 bin/sh/sh.1 |  12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diffs (26 lines):

diff -r 33441b357608 -r da7d802f3326 bin/sh/sh.1
--- a/bin/sh/sh.1       Thu May 12 13:05:18 2016 +0000
+++ b/bin/sh/sh.1       Thu May 12 13:15:43 2016 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: sh.1,v 1.122 2016/05/09 20:36:07 kre Exp $
+.\"    $NetBSD: sh.1,v 1.123 2016/05/12 13:15:43 kre Exp $
 .\" Copyright (c) 1991, 1993
 .\"    The Regents of the University of California.  All rights reserved.
 .\"
@@ -1538,6 +1538,16 @@
 (except
 .Xr ksh 1 ) ,
 made those file descriptors available to exec'ed processes.
+To turn off the close-on-exec mark,
+redirect the descriptor to (or from) itself,
+either when invoking a command for which the descriptor is wanted open,
+or by using
+.Ic exec
+(perhaps the same
+.Ic exec
+as opened it, after the open)
+to leave the descriptor open in the shell
+and pass it to all commands invoked subsequently.
 .It exit Op Ar exitstatus
 Terminate the shell process.
 If



Home | Main Index | Thread Index | Old Index