From fbd1b9e4fb6a1983bdb1eff3f8d34f8ee62cd6ea Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Tue, 20 Jul 2010 22:11:14 -0600 Subject: [PATCH] Close job control fd before running tests. * doc/autoconf.texi (File Descriptors): Clarify limitations. * lib/autotest/general.m4 (AT_CLEANUP): Avoid leaking job control fifo fd to user tests. (AT_INIT): Delete comment, now that close is done elsewhere. Suggested by Ralf Wildenhues. Signed-off-by: Eric Blake --- ChangeLog | 9 +++++++++ doc/autoconf.texi | 8 +++++++- lib/autotest/general.m4 | 4 ++-- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index e9146c31..2544b762 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2010-07-20 Eric Blake + + Close job control fd before running tests. + * doc/autoconf.texi (File Descriptors): Clarify limitations. + * lib/autotest/general.m4 (AT_CLEANUP): Avoid leaking job control + fifo fd to user tests. + (AT_INIT): Delete comment, now that close is done elsewhere. + Suggested by Ralf Wildenhues. + 2010-07-20 Paul Eggert and Eric Blake diff --git a/doc/autoconf.texi b/doc/autoconf.texi index c47d5103..c3a8714a 100644 --- a/doc/autoconf.texi +++ b/doc/autoconf.texi @@ -15006,7 +15006,7 @@ $ Within the process which runs the @samp{descrips} script, file descriptor 5 is closed. -Don't rely on redirection to a closed file descriptor to cause an +Don't rely on duplicating a closed file descriptor to cause an error. With Solaris @command{/bin/sh}, when the redirection fails, the output goes to the original file descriptor. @@ -15019,6 +15019,12 @@ hi 0 @end example +Fortunately, an attempt to close an already closed file descriptor will +portably succeed. Likewise, it is safe to use either style of +@samp{@var{n}<&-} or @samp{@var{n}>&-} for closing a file descriptor, +even if it doesn't match the read/write mode that the file descriptor +was opened with. + DOS variants cannot rename or remove open files, such as in @samp{mv foo bar >foo} or @samp{rm foo >foo}, even though this is perfectly portable among Posix hosts. diff --git a/lib/autotest/general.m4 b/lib/autotest/general.m4 index f328ef4d..4acdb9d2 100644 --- a/lib/autotest/general.m4 +++ b/lib/autotest/general.m4 @@ -1405,7 +1405,7 @@ dnl kill -13 $$ at_fn_group_prepare if cd "$at_group_dir" && at_fn_test $at_group && - . "$at_test_source" [#] AT_JOB_FIFO_OUT_FD>&- + . "$at_test_source" then :; else AS_WARN([unable to parse test group: $at_group]) at_failed=: @@ -1917,7 +1917,7 @@ echo "# -*- compilation -*-" >> "$at_group_log" m4_undivert([TEST_SCRIPT])dnl Insert the code here set +x $at_times_p && times >"$at_times_file" -) AS_MESSAGE_LOG_FD>&1 2>&1 | eval $at_tee_pipe +) AS_MESSAGE_LOG_FD>&1 2>&1 AT_JOB_FIFO_OUT_FD>&- | eval $at_tee_pipe read at_status <"$at_status_file" [#AT_STOP_]AT_ordinal m4_divert_pop([TEST_GROUPS])dnl Back to KILL. -- 2.47.2