diff options
author | Jim Meyering <jim@meyering.net> | 2007-01-20 16:33:20 +0100 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2007-01-20 16:33:20 +0100 |
commit | 94986c1d0a35fa233ab80fe65fb6e3e93a8c2196 (patch) | |
tree | 3aa7a830ed4d42516673ea785e5ffa4ac9219376 | |
parent | c12e44d8915721dd70429ae7954129a622f16b9a (diff) | |
parent | bdbd5d31f810a33f4922d63b1852ab96a5fc4a01 (diff) | |
download | coreutils-94986c1d0a35fa233ab80fe65fb6e3e93a8c2196.tar.xz |
Merge branch 'master' of /cu
-rw-r--r-- | ChangeLog | 59 | ||||
-rw-r--r-- | NEWS | 2 | ||||
-rwxr-xr-x | bootstrap | 20 | ||||
-rw-r--r-- | bootstrap.conf | 9 | ||||
-rw-r--r-- | doc/ChangeLog | 5 | ||||
-rw-r--r-- | doc/coreutils.texi | 7 | ||||
-rw-r--r-- | lib/.cvsignore | 12 | ||||
-rw-r--r-- | lib/.gitignore | 16 | ||||
-rw-r--r-- | lib/ChangeLog | 9 | ||||
-rw-r--r-- | lib/fchdir-stub.c | 14 | ||||
-rw-r--r-- | m4/.cvsignore | 2 | ||||
-rw-r--r-- | m4/.gitignore | 2 | ||||
-rw-r--r-- | m4/ChangeLog | 4 | ||||
-rw-r--r-- | m4/jm-macros.m4 | 4 | ||||
-rw-r--r-- | src/c99-to-c89.diff | 6 | ||||
-rw-r--r-- | src/csplit.c | 21 | ||||
-rw-r--r-- | src/ls.c | 25 | ||||
-rw-r--r-- | src/mv.c | 4 | ||||
-rw-r--r-- | src/remove.c | 14 | ||||
-rw-r--r-- | src/remove.h | 13 | ||||
-rw-r--r-- | src/rm.c | 18 | ||||
-rw-r--r-- | src/sort.c | 46 | ||||
-rw-r--r-- | tests/rm/Makefile.am | 3 | ||||
-rwxr-xr-x | tests/rm/i-never | 53 |
24 files changed, 314 insertions, 54 deletions
@@ -1,3 +1,62 @@ +2007-01-20 Paul Eggert <eggert@cs.ucla.edu> + + Standardize on list of signals when an app catches signals. + * src/csplit.c (main): Also catch SIGALRM, SIGPIPE, SIGPOLL, + SIGPROF, SIGVTALRM, SIGXCPU, SIGXFSZ. + * src/ls.c (main): Likewise (except SIGPIPE was already caught). + Note that ls.c is special, as it also catches SIGTSTP. + * src/sort.c (main): Likewise. Also catch SIGQUIT. More details in + <http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/9510>. + +2007-01-19 Dan Hipschman <dsh@linux.ucla.edu> + and Paul Eggert <eggert@cs.ucla.edu> + + * src/sort.c (cleanup): Clear temphead at the end. + (exit_cleanup): New function. + (main): Don't invoke atexit until we're ready. + Invoke it with exit_cleanup, not with cleanup and close_stdout, + to avoid a race condition with cleanup and signal handling. More + details: http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/9508 + +2007-01-18 Jim Meyering <jim@meyering.net> + + * src/c99-to-c89.diff: Adjust remove.c offsets. + +2007-01-17 Jim Meyering <jim@meyering.net> + + Make "rm --interactive=never ..." never prompt. + * NEWS: Mention this. + * src/remove.h (enum rm_interactive): New ternary type. + (struct rm_options) [interactive]: Use it, here -- rather than bool. + * src/remove.c (prompt): Reflect type change. + * src/mv.c (rm_option_init): Initialize to RMI_NEVER now. + * src/rm.c (main): Add a FIXME comment for '-d' option. + Adapt to type change of rm_options.interactive. + + * tests/rm/i-never: New file. Test for the above fix. + * tests/rm/Makefile.am (TESTS): Add i-never. + +2007-01-15 Jim Meyering <jim@meyering.net> + + * bootstrap (gnulib_tool): When adding to .cvsignore and .gitignore, + emit foo.h, for each foo_.h. This yields one false-positive, fts.h, + but that's ok, since fts_.h will eventually be renamed. + + * src/remove.c (remove_dir): Don't use errno in diagnostic. + Root-only test failure reported by Alex van Hout and Jon Grosshart in + <http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/9415/focus=9415>. + + * bootstrap.conf (avoided_gnulib_modules): Fix my typo: + s/--avoid=canonicalize-lgpl/--avoid=canonicalize-gpl/ + +2007-01-14 Bruno Haible <bruno@clisp.org> + + Enable use of gnulib's new fchdir module. + * bootstrap.conf (avoided_gnulib_modules): Avoid canonicalize-lgpl, + since we use canonicalize. + (gnulib_modules): Add fchdir. + * m4/jm-macros.m4 (coreutils_MACROS): Remove fchdir-stub. + 2007-01-13 Jim Meyering <jim@meyering.net> * tests/cp/open-perm-race: Remove gdb-based test. @@ -27,6 +27,8 @@ GNU coreutils NEWS -*- outline -*- "rm -rf /etc/passwd" (run by non-root) now prints a diagnostic. Before it would print nothing. + "rm --interactive=never F" no longer prompts for an unwritable F + * Noteworthy changes in release 6.7 (2006-12-08) [stable] @@ -2,7 +2,7 @@ # Bootstrap this package from CVS. -# Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc. +# Copyright (C) 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -350,6 +350,16 @@ version_controlled_file() { test $found = yes } +# If $STR is not already on a line by itself in $FILE, insert it, +# sorting the new contents of the file and replacing $FILE with the result. +insert_sorted_if_absent() { + file=$1 + str=$2 + echo "$str" | sort -u - $file | cmp -s - $file \ + || echo "$str" | sort -u - $file -o $file \ + || exit +} + slurp() { for dir in . `(cd $1 && find * -type d -print)`; do copied= @@ -392,8 +402,12 @@ slurp() { for dot_ig in .cvsignore .gitignore; do ig=$dir/$dot_ig if test -n "$copied" && test -f $ig; then - echo "$copied" | sort -u - $ig | cmp -s - $ig || - echo "$copied" | sort -u - $ig -o $ig || exit + insert_sorted_if_absent $ig "$copied" + # If an ignored file name ends with _.h, then also add + # the name with just ".h". Many gnulib headers are generated, + # e.g., stdint_.h -> stdint.h, dirent_.h ->..., etc. + f=`echo "$copied"|sed 's/_\.h$/.h/'` + insert_sorted_if_absent $ig "$f" fi done done diff --git a/bootstrap.conf b/bootstrap.conf index 41d925fa9..73e7d4926 100644 --- a/bootstrap.conf +++ b/bootstrap.conf @@ -1,6 +1,6 @@ # Bootstrap configuration. -# Copyright (C) 2006 Free Software Foundation, Inc. +# Copyright (C) 2006, 2007 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -19,11 +19,12 @@ # We don't need these modules, even though gnulib-tool mistakenly -# includes them because of gettext dependencies. +# includes them because of gettext and fchdir dependencies. avoided_gnulib_modules=' --avoid=lock --avoid=size_max --avoid=xsize + --avoid=canonicalize-lgpl ' # These modules are obsolete and can probably be removed soon, @@ -41,8 +42,8 @@ gnulib_modules=" c-strtold calloc canon-host canonicalize chown cloexec config-h configmake closeout cycle-check d-ino d-type diacrit dirfd dirname dup2 - error euidaccess exclude exitfail fcntl fcntl-safer fdl file-type - fileblocks filemode filenamecat fnmatch-gnu fopen-safer + error euidaccess exclude exitfail fchdir fcntl fcntl-safer fdl + file-type fileblocks filemode filenamecat fnmatch-gnu fopen-safer fprintftime fsusage ftruncate fts getdate getgroups gethrxtime getline getloadavg getndelim2 getopt getpagesize getpass-gnu gettext gettime gettimeofday getugroups getusershell gnupload diff --git a/doc/ChangeLog b/doc/ChangeLog index 5f590af3f..a9c6d295e 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,8 @@ +2007-01-19 Jim Meyering <jim@meyering.net> + + * coreutils.texi (ls: General output formatting): Mention the + workarounds to accommodate the Apple Terminal bug. + 2007-01-04 Jim Meyering <jim@meyering.net> * coreutils.texi (base64 invocation): When decoding, newlines diff --git a/doc/coreutils.texi b/doc/coreutils.texi index 6fc670479..89e97d8bc 100644 --- a/doc/coreutils.texi +++ b/doc/coreutils.texi @@ -6419,6 +6419,13 @@ Assume that each tab stop is @var{cols} columns wide. The default is 8. @command{ls} uses tabs where possible in the output, for efficiency. If @var{cols} is zero, do not use tabs at all. +@c FIXME: remove in 2009, if Apple Terminal has been fixed for long enough. +Some terminal emulators (at least Apple Terminal 1.5 (133) from Mac OS X 10.4.8) +do not properly align columns to the right of a TAB following a +non-@acronym{ASCII} byte. If you use such a terminal emulator, use the +@option{-T0} option or put @code{TABSIZE=0} in your environment to tell +@command{ls} to align using spaces, not tabs. + @item -w @itemx --width=@var{cols} @opindex -w diff --git a/lib/.cvsignore b/lib/.cvsignore index f31e3d510..fb5f9e0ea 100644 --- a/lib/.cvsignore +++ b/lib/.cvsignore @@ -52,6 +52,8 @@ diacrit.c diacrit.h dirchownmod.c dirchownmod.h +dirent.h +dirent_.h dirfd.c dirfd.h dirname.c @@ -67,6 +69,7 @@ exclude.h exit.h exitfail.c exitfail.h +fchdir.c fchmodat.c fchown-stub.c fchownat.c @@ -281,10 +284,12 @@ sig2str.c sig2str.h snprintf.c snprintf.h +socket.h socket_.h stamp-h1 stat-macros.h stat-time.h +stat.h stat_.h stdbool.h stdbool_.h @@ -322,6 +327,9 @@ strtoull.c strtoumax.c strverscmp.c strverscmp.h +sys +sys_time.h +sys_time_.h t-fpending tempname.c tempname.h @@ -333,6 +341,8 @@ umaxtostr.c unicodeio.h unistd--.h unistd-safer.h +unistd.h +unistd_.h unlinkdir.c unlinkdir.h unlocked-io.h @@ -351,7 +361,9 @@ verify.h version-etc-fsf.c version-etc.c version-etc.h +wchar.h wchar_.h +wctype.h wctype_.h wcwidth.h xalloc-die.c diff --git a/lib/.gitignore b/lib/.gitignore index 08160d728..1ebe1d47d 100644 --- a/lib/.gitignore +++ b/lib/.gitignore @@ -47,6 +47,8 @@ diacrit.c diacrit.h dirchownmod.c dirchownmod.h +dirent.h +dirent_.h dirfd.c dirfd.h dirname.c @@ -62,6 +64,7 @@ exclude.h exit.h exitfail.c exitfail.h +fchdir.c fchmodat.c fchown-stub.c fchownat.c @@ -78,6 +81,7 @@ filemode.h filenamecat.c filenamecat.h fnmatch.c +fnmatch.h fnmatch_.h fnmatch_loop.c fopen-safer.c @@ -90,6 +94,7 @@ fsusage.h ftruncate.c fts-cycle.c fts.c +fts.h fts_.h full-read.c full-read.h @@ -115,6 +120,7 @@ getloadavg.c getndelim2.c getndelim2.h getopt.c +getopt.h getopt1.c getopt_.h getopt_int.h @@ -270,10 +276,13 @@ sig2str.c sig2str.h snprintf.c snprintf.h +socket.h socket_.h stat-macros.h stat-time.h +stat.h stat_.h +stdbool.h stdbool_.h stdint.h stdint_.h @@ -309,6 +318,9 @@ strtoull.c strtoumax.c strverscmp.c strverscmp.h +sys +sys_time.h +sys_time_.h t-fpending tempname.c tempname.h @@ -320,6 +332,8 @@ umaxtostr.c unicodeio.h unistd--.h unistd-safer.h +unistd.h +unistd_.h unlinkdir.c unlinkdir.h unlocked-io.h @@ -338,7 +352,9 @@ verify.h version-etc-fsf.c version-etc.c version-etc.h +wchar.h wchar_.h +wctype.h wctype_.h wcwidth.h xalloc-die.c diff --git a/lib/ChangeLog b/lib/ChangeLog index 99ede8dbf..793a227f9 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,12 @@ +2007-01-19 Jim Meyering <jim@meyering.net> + + * .cvsignore, .gitignore: Add sys, as well as more + bootstrap-inserted file names. + +2007-01-14 Jim Meyering <jim@meyering.net> + + * fchdir-stub.c: Remove file. No longer needed. + 2006-12-03 Jim Meyering <jim@meyering.net> * Makefile.am (libcoreutils_a_SOURCES): Remove xmemcoll.c and diff --git a/lib/fchdir-stub.c b/lib/fchdir-stub.c deleted file mode 100644 index 922236211..000000000 --- a/lib/fchdir-stub.c +++ /dev/null @@ -1,14 +0,0 @@ -#include <config.h> -#include <sys/types.h> -#include <errno.h> - -/* A trivial substitute for `fchdir'. - - DJGPP 2.03 and earlier don't have `fchdir'. */ - -int -fchdir (int fd) -{ - errno = ENOSYS; - return -1; -} diff --git a/m4/.cvsignore b/m4/.cvsignore index 2a47a7ba0..0311ce8c1 100644 --- a/m4/.cvsignore +++ b/m4/.cvsignore @@ -37,6 +37,7 @@ euidaccess.m4 exclude.m4 exitfail.m4 extensions.m4 +fchdir.m4 fcntl-safer.m4 fcntl_h.m4 file-type.m4 @@ -207,6 +208,7 @@ strtoumax.m4 strverscmp.m4 sys_socket_h.m4 sys_stat_h.m4 +sys_time_h.m4 tempname.m4 time_r.m4 timespec.m4 diff --git a/m4/.gitignore b/m4/.gitignore index 673615c1c..e6ae77991 100644 --- a/m4/.gitignore +++ b/m4/.gitignore @@ -36,6 +36,7 @@ euidaccess.m4 exclude.m4 exitfail.m4 extensions.m4 +fchdir.m4 fcntl-safer.m4 fcntl_h.m4 file-type.m4 @@ -199,6 +200,7 @@ strtoumax.m4 strverscmp.m4 sys_socket_h.m4 sys_stat_h.m4 +sys_time_h.m4 tempname.m4 time_r.m4 timespec.m4 diff --git a/m4/ChangeLog b/m4/ChangeLog index 92e8f5f05..25cac3a2d 100644 --- a/m4/ChangeLog +++ b/m4/ChangeLog @@ -1,3 +1,7 @@ +2007-01-19 Jim Meyering <jim@meyering.net> + + * .cvsignore, .gitignore: Add more bootstrap-inserted file names. + 2006-12-12 Jim Meyering <jim@meyering.net> * jm-macros.m4: Remove AC_FUNC_SETVBUF_REVERSED, now that it's a no-op. diff --git a/m4/jm-macros.m4 b/m4/jm-macros.m4 index fe9970b50..2595542f9 100644 --- a/m4/jm-macros.m4 +++ b/m4/jm-macros.m4 @@ -109,10 +109,6 @@ AC_DEFUN([coreutils_MACROS], if test $gl_cv_list_mounted_fs = yes && test $gl_cv_fs_space = yes; then DF_PROG='df$(EXEEXT)' fi - - # If any of these functions don't exist (e.g. DJGPP 2.03), - # use the corresponding stub. - AC_CHECK_FUNC([fchdir], , [AC_LIBOBJ(fchdir-stub)]) ]) AC_DEFUN([gl_CHECK_ALL_HEADERS], diff --git a/src/c99-to-c89.diff b/src/c99-to-c89.diff index 68513f50b..04db772c4 100644 --- a/src/c99-to-c89.diff +++ b/src/c99-to-c89.diff @@ -31,7 +31,7 @@ index 4728bdd..7477da5 100644 if (top->unremovable) hash_free (top->unremovable); obstack_blank (&ds->Active_dir, -(int) sizeof (struct AD_ent)); -@@ -1477,6 +1479,7 @@ rm_1 (Dirstack_state *ds, char const *fi +@@ -1481,6 +1483,7 @@ rm_1 (Dirstack_state *ds, char const *fi return RM_ERROR; } @@ -39,7 +39,7 @@ index 4728bdd..7477da5 100644 struct stat st; cache_stat_init (&st); cycle_check_init (&ds->cycle_check_state); -@@ -1499,6 +1502,7 @@ rm_1 (Dirstack_state *ds, char const *fi +@@ -1503,6 +1506,7 @@ rm_1 (Dirstack_state *ds, char const *fi AD_push_initial (ds); AD_INIT_OTHER_MEMBERS (); @@ -47,7 +47,7 @@ index 4728bdd..7477da5 100644 enum RM_status status = remove_entry (AT_FDCWD, ds, filename, &st, x, NULL); if (status == RM_NONEMPTY_DIR) { -@@ -1515,6 +1519,8 @@ rm_1 (Dirstack_state *ds, char const *fi +@@ -1519,6 +1523,8 @@ rm_1 (Dirstack_state *ds, char const *fi ds_clear (ds); return status; diff --git a/src/csplit.c b/src/csplit.c index 382fd6621..a26c80df3 100644 --- a/src/csplit.c +++ b/src/csplit.c @@ -1402,7 +1402,26 @@ main (int argc, char **argv) { int i; - static int const sig[] = { SIGHUP, SIGINT, SIGQUIT, SIGTERM }; + static int const sig[] = + { + /* The usual suspects. */ + SIGALRM, SIGHUP, SIGINT, SIGPIPE, SIGQUIT, SIGTERM, +#ifdef SIGPOLL + SIGPOLL, +#endif +#ifdef SIGPROF + SIGPROF, +#endif +#ifdef SIGVTALRM + SIGVTALRM, +#endif +#ifdef SIGXCPU + SIGXCPU, +#endif +#ifdef SIGXFSZ + SIGXFSZ, +#endif + }; enum { nsigs = sizeof sig / sizeof sig[0] }; #if SA_NOCLDSTOP @@ -1113,8 +1113,29 @@ main (int argc, char **argv) int n_files; /* The signals that are trapped, and the number of such signals. */ - static int const sig[] = { SIGHUP, SIGINT, SIGPIPE, - SIGQUIT, SIGTERM, SIGTSTP }; + static int const sig[] = + { + /* This one is handled specially. */ + SIGTSTP, + + /* The usual suspects. */ + SIGALRM, SIGHUP, SIGINT, SIGPIPE, SIGQUIT, SIGTERM, +#ifdef SIGPOLL + SIGPOLL, +#endif +#ifdef SIGPROF + SIGPROF, +#endif +#ifdef SIGVTALRM + SIGVTALRM, +#endif +#ifdef SIGXCPU + SIGXCPU, +#endif +#ifdef SIGXFSZ + SIGXFSZ, +#endif + }; enum { nsigs = sizeof sig / sizeof sig[0] }; #if ! SA_NOCLDSTOP @@ -1,5 +1,5 @@ /* mv -- move or rename files - Copyright (C) 86, 89, 90, 91, 1995-2006 Free Software Foundation, Inc. + Copyright (C) 86, 89, 90, 91, 1995-2007 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -98,7 +98,7 @@ rm_option_init (struct rm_options *x) /* Should we prompt for removal, too? No. Prompting for the `move' part is enough. It implies removal. */ - x->interactive = 0; + x->interactive = RMI_NEVER; x->stdin_tty = false; x->verbose = false; diff --git a/src/remove.c b/src/remove.c index 7e8645137..97184eb26 100644 --- a/src/remove.c +++ b/src/remove.c @@ -1,5 +1,5 @@ /* remove.c -- core functions for removing files and directories - Copyright (C) 88, 90, 91, 1994-2006 Free Software Foundation, Inc. + Copyright (C) 88, 90, 91, 1994-2007 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -798,10 +798,14 @@ prompt (int fd_cwd, Dirstack_state const *ds, char const *filename, *is_empty = T_UNKNOWN; - if (((!x->ignore_missing_files & (x->interactive | x->stdin_tty)) + if (x->interactive == RMI_NEVER) + return RM_OK; + + if (((!x->ignore_missing_files & ((x->interactive == RMI_ALWAYS) + | x->stdin_tty)) && (write_protected = write_protected_non_symlink (fd_cwd, filename, ds, sbuf))) - || x->interactive) + || x->interactive == RMI_ALWAYS) { if (cache_fstatat (fd_cwd, filename, sbuf, AT_SYMLINK_NOFOLLOW) != 0) { @@ -821,7 +825,7 @@ prompt (int fd_cwd, Dirstack_state const *ds, char const *filename, /* Using permissions doesn't make sense for symlinks. */ if (S_ISLNK (sbuf->st_mode)) { - if ( ! x->interactive) + if (x->interactive != RMI_ALWAYS) return RM_OK; write_protected = false; } @@ -1371,7 +1375,7 @@ remove_dir (int fd_cwd, Dirstack_state *ds, char const *dir, traversal into the current directory, (known as SUBDIR, from ..), DIRP's device number is different from CURRENT_DEV. Arrange not to do anything more with this hierarchy. */ - error (0, errno, _("skipping %s, since it's on a different device"), + error (0, 0, _("skipping %s, since it's on a different device"), quote (full_filename (subdir))); free (subdir); AD_mark_current_as_unremovable (ds); diff --git a/src/remove.h b/src/remove.h index 2dc617618..ae01e3c6c 100644 --- a/src/remove.h +++ b/src/remove.h @@ -1,6 +1,6 @@ /* Remove directory entries. - Copyright (C) 1998, 2000, 2002, 2003, 2004, 2005, 2006 Free + Copyright (C) 1998, 2000, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify @@ -22,13 +22,22 @@ # include "dev-ino.h" +enum rm_interactive +{ + /* Start with any number larger than 1, so that any legacy tests + against values of 0 or 1 will fail. */ + RMI_ALWAYS = 3, + RMI_SOMETIMES, + RMI_NEVER +}; + struct rm_options { /* If true, ignore nonexistent files. */ bool ignore_missing_files; /* If true, query the user about whether to remove each file. */ - bool interactive; + enum rm_interactive interactive; /* If true, do not traverse into (or remove) any directory that is on a file system (i.e., that has a different device number) other @@ -1,5 +1,5 @@ /* `rm' file deletion utility for GNU. - Copyright (C) 88, 90, 91, 1994-2006 Free Software Foundation, Inc. + Copyright (C) 88, 90, 91, 1994-2007 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -213,7 +213,7 @@ static void rm_option_init (struct rm_options *x) { x->ignore_missing_files = false; - x->interactive = false; + x->interactive = RMI_SOMETIMES; x->one_file_system = false; x->recursive = false; x->root_dev_ino = NULL; @@ -249,25 +249,25 @@ main (int argc, char **argv) { case 'd': /* Ignore this option, for backward compatibility with - coreutils 5.92. Some time after 2005, we'll change this + coreutils 5.92. FIXME: Some time after 2005, change this to report an error (or perhaps behave like FreeBSD does) instead of ignoring the option. */ break; case 'f': - x.interactive = false; + x.interactive = RMI_NEVER; x.ignore_missing_files = true; prompt_once = false; break; case 'i': - x.interactive = true; + x.interactive = RMI_ALWAYS; x.ignore_missing_files = false; prompt_once = false; break; case 'I': - x.interactive = false; + x.interactive = RMI_NEVER; x.ignore_missing_files = false; prompt_once = true; break; @@ -288,18 +288,18 @@ main (int argc, char **argv) switch (i) { case interactive_never: - x.interactive = false; + x.interactive = RMI_NEVER; prompt_once = false; break; case interactive_once: - x.interactive = false; + x.interactive = RMI_SOMETIMES; x.ignore_missing_files = false; prompt_once = true; break; case interactive_always: - x.interactive = true; + x.interactive = RMI_ALWAYS; x.ignore_missing_files = false; prompt_once = false; break; diff --git a/src/sort.c b/src/sort.c index f03237cb3..8a2279637 100644 --- a/src/sort.c +++ b/src/sort.c @@ -417,6 +417,25 @@ cleanup (void) for (node = temphead; node; node = node->next) unlink (node->name); + temphead = NULL; +} + +/* Cleanup actions to take when exiting. */ + +static void +exit_cleanup (void) +{ + if (temphead) + { + /* Clean up any remaining temporary files in a critical section so + that a signal handler does not try to clean them too. */ + sigset_t oldset; + sigprocmask (SIG_BLOCK, &caught_signals, &oldset); + cleanup (); + sigprocmask (SIG_SETMASK, &oldset, NULL); + } + + close_stdout (); } /* Create a new temporary file, returning its newly allocated name. @@ -2302,10 +2321,7 @@ main (int argc, char **argv) bindtextdomain (PACKAGE, LOCALEDIR); textdomain (PACKAGE); - atexit (cleanup); - initialize_exit_failure (SORT_FAILURE); - atexit (close_stdout); hard_LC_COLLATE = hard_locale (LC_COLLATE); #if HAVE_NL_LANGINFO @@ -2334,7 +2350,26 @@ main (int argc, char **argv) { size_t i; - static int const sig[] = { SIGHUP, SIGINT, SIGPIPE, SIGTERM }; + static int const sig[] = + { + /* The usual suspects. */ + SIGALRM, SIGHUP, SIGINT, SIGPIPE, SIGQUIT, SIGTERM, +#ifdef SIGPOLL + SIGPOLL, +#endif +#ifdef SIGPROF + SIGPROF, +#endif +#ifdef SIGVTALRM + SIGVTALRM, +#endif +#ifdef SIGXCPU + SIGXCPU, +#endif +#ifdef SIGXFSZ + SIGXFSZ, +#endif + }; enum { nsigs = sizeof sig / sizeof sig[0] }; #if SA_NOCLDSTOP @@ -2365,6 +2400,9 @@ main (int argc, char **argv) #endif } + /* The signal mask is known, so it is safe to invoke exit_cleanup. */ + atexit (exit_cleanup); + gkey.sword = gkey.eword = SIZE_MAX; gkey.ignore = NULL; gkey.translate = NULL; diff --git a/tests/rm/Makefile.am b/tests/rm/Makefile.am index ff31f7518..4c212b9d6 100644 --- a/tests/rm/Makefile.am +++ b/tests/rm/Makefile.am @@ -1,6 +1,6 @@ # Make coreutils tests for "rm". -*-Makefile-*- -# Copyright (C) 1997, 1998, 2000, 2001, 2002, 2003, 2004, 2005, 2006 +# Copyright (C) 1997, 1998, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 # Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify @@ -21,6 +21,7 @@ AUTOMAKE_OPTIONS = 1.1 gnits TESTS = \ + i-never \ fail-eacces \ one-file-system \ ignorable \ diff --git a/tests/rm/i-never b/tests/rm/i-never new file mode 100755 index 000000000..f20e90e78 --- /dev/null +++ b/tests/rm/i-never @@ -0,0 +1,53 @@ +#!/bin/sh +# Ensure that rm --interactive=never works does not prompt, even for +# an unwritable file. + +# Copyright (C) 2007 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. + +if test "$VERBOSE" = yes; then + set -x + rm --version +fi + +PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check + +pwd=`pwd` +t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$ +trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0 +trap '(exit $?); exit $?' 1 2 13 15 + +framework_failure=0 +mkdir -p $tmp || framework_failure=1 +cd $tmp || framework_failure=1 +touch f || framework_failure=1 +chmod 0 f || framework_failure=1 +touch exp || framework_failure=1 + +if test $framework_failure = 1; then + echo "$0: failure in testing framework" 1>&2 + (exit 1); exit 1 +fi + +fail=0 + +rm --interactive=never f > out || fail=1 + +cmp out exp || fail=1 +test $fail = 1 && diff out exp 2> /dev/null + +(exit $fail); exit $fail |