Module Name: src Committed By: kre Date: Thu May 12 13:15:43 UTC 2016
Modified Files: src/bin/sh: sh.1 Log Message: 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@ To generate a diff of this commit: cvs rdiff -u -r1.122 -r1.123 src/bin/sh/sh.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/bin/sh/sh.1 diff -u src/bin/sh/sh.1:1.122 src/bin/sh/sh.1:1.123 --- src/bin/sh/sh.1:1.122 Mon May 9 20:36:07 2016 +++ src/bin/sh/sh.1 Thu May 12 13:15:43 2016 @@ -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 @@ Traditionally Bourne-like shells (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