autoconf-patches
[Top][All Lists]
Advanced

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

ksh closes file descriptors on exec -- patch to autoconf.texi


From: Norman Gray
Subject: ksh closes file descriptors on exec -- patch to autoconf.texi
Date: Thu, 2 Jun 2005 16:32:30 +0200


Greetings,

May I suggest the following patch to the `Portable Shell Programming' section of autoconf.texi? On Tru64 at least, ./configure scripts will prefer ksh to /bin/sh because the latter doesn't implement $LINENO properly (is that _really_ so important, says he plaintively...?)

All the best,

Norman


------------------
Basil:doc> diff -c autoconf.texi{.~1.5.~,}
*** autoconf.texi.~1.5.~        Thu Jun 17 20:16:11 2004
--- autoconf.texi       Thu Jun  2 16:23:51 2005
***************
*** 9620,9625 ****
--- 9620,9651 ----
Don't try to move/delete open files, such as in @samp{exec >foo; mv foo bar}; see @ref{Limitations of Builtins}, @command{mv} for more details.

+ Don't rely on open file descriptors being open in child processes.  In
+ @command{ksh}, file descriptors above 2 which are opened using
+ @samp{exec n>file} are closed by a subsequent @samp{exec} (such as
+ that involved in the fork-and-exec which runs a program or script).
+ Thus, using sh, we have:
+ @example
+ $ cat ./descrips
+ #! /bin/sh -
+ echo hello >&5
+ $ exec 5>t
+ $ ./descrips
+ $ cat t
+ hello
+ $
+ @end example
+ But using ksh:
+ @example
+ $ exec 5>t
+ $ ./descrips
+ hello
+ $ cat t
+ $
+ @end example
+ Within the process which runs the @samp{descrips} script, file
+ descriptor number 5 is closed.
+
  @node File System Conventions
  @section File System Conventions

---------------

--
----------------------------------------------------------------------
Norman Gray  :  Physics & Astronomy, Glasgow University, UK
http://www.astro.gla.ac.uk/users/norman/  :  www.starlink.ac.uk





reply via email to

[Prev in Thread] Current Thread [Next in Thread]