Commit Graph
4344 Commits
Author SHA1 Message Date
Jim Meyering 48d44f4301 . 2004-04-24 08:09:52 +00:00
Jim Meyering adc30a8396 More signal-handling cleanup for ls.c. Do not allow signals to
happen between arbitrary output bytes, as the
restore-default-color sequence can bollix up multibyte chars or
color-change sequences in the ordinary output.  Instead, process
signals only between printing a file name and changing the color
back to non_filename_text color.  That way, if the signal handler
changes the color (to the default), 'ls' will change it back when
'ls' continues (after being suspended).

Also, do not bother with signal-handling unless stdout is a
controlling terminal; this lets stdio buffer better when "ls
--color" is piped or sent to a file.

(sigprocmask, sigset_t) [!defined SA_NOCLDSTOP]: New macros.
Do not include "full-write.h"; no longer needed.
(tcgetpgrp) [! HAVE_TCGETPGRP]: New macro.
(put_indicator_direct): Remove.  All callers changed to use
put_indicator.
(caught_signals, interrupt_signal, stop_signal_count): New vars.
(restore_default_color): Don't bother checking for put_indicator
failure.
(sighandler): Don't handle SIGTSTP; that's another handler now.
Simply set interrupt_signal to the signal, then exit.
(stophandler, process_signals): New functions.
(main): Don't output any color changes until _after_ the signal
handlers are set up.  This fixes a race condition where 'ls'
could be interrupted while initializing colors, and leaving the
terminal in an undesirable state.
Don't mess with signal-handling if standard output is not a
controlling terminal.
When exiting, restore the default color, then restore the
default signal handling, then act on any signals that weren't
acted on yet.
Do not print //DIRED// etc. in colors; this avoids the need
to catch signals when printing them.
(print_name_with_quoting): Process signals just before switching
color back to non_filename_text.
2004-04-24 08:03:15 +00:00
Jim Meyering e356a9a6ea Avoid segfault on systems for which SIZE_MAX != (size_t) -1.
(quote_name): Use SIZE_MAX, not -1, in calls of quotearg_buffer.
Patch by Mikulas Patocka.
2004-04-23 17:32:25 +00:00
Jim Meyering ed4778772c (main): Do not ignore SIGPIPE, as POSIX 1003.1-2001
does not allow this.  This undoes the 1996-10-24 patch.
2004-04-21 14:26:09 +00:00
Jim Meyering 8ab60c41be - csplit sometimes failed to remove files when interrupted.
- csplit didn't clean up if two signals arrived nearly simultaneously.

(sigprocmask, sigset_t) [!defined SA_NOCLDSTOP]: Define.
(filename_space, prefix, suffix, digits, files_created, remove_files): Now volatile.
(caught_signals): New var.
(cleanup): Block signals while deleting all files.
(cleanup_fatal, handle_line_error, regexp_error):
Mark with ATTRIBUTE_NORETURN.
(create_output_file, close_output_file, interrupt_handler):
Block signals while changing the number of output files,
to fix some race conditions.
(delete_all_files): Do nothing if remove_files is zero.
Clear files_created.
(main): Don't mess with signals until after argument processing is done.

(main): Rewrite signal-catching code to make it
similar to other coreutils programs.  When processing signals,
block all signals that we catch, but do not block signals that we
don't catch.  Avoid problems with unsigned int warnings.

(interrupt_handler): Use void, not (obsolete) RETSIGTYPE.

(interrupt_handler) [defined SA_NOCLDSTOP]:
Use simpler "signal (sig, SIG_DFL)" rather than sigaction equivalent.
2004-04-21 12:57:33 +00:00
Jim Meyering eae1b7f862 - ls could incorrectly restore color if multiple signals
arrived nearly simultaneously.

(main): Rewrite signal-catching code to make it
similar to other coreutils programs.  When processing signals,
block all signals that we catch, but do not block signals that we
don't catch.  Avoid problems with unsigned int warnings.

(sighandler) [defined SA_NOCLDSTOP]:
Use simpler "signal (sig, SIG_DFL)" rather than sigaction equivalent.

(sighandler) [!defined SA_NOCLDSTOP]: Reset signal
handler to self, not to SIG_IGN, since SIGTSTP can be received more than once.
(main): Use SA_RESTART, as that is simpler than checking for EINTR
failures all over the place.
2004-04-21 12:51:27 +00:00
Jim Meyering 4441496397 install -s failed on System V if SIGCHLD was ignored.
Include <signal.h>.
(main) [defined SIGCHLD]: Set SIGCHLD handler to the default,
if -s is given, since System V fork+wait does not work if SIGCHLD
is ignored.
2004-04-21 12:25:18 +00:00
Jim Meyering f4e0a51788 (is_empty_dir): Clarify comment. 2004-04-20 18:13:43 +00:00
Jim Meyering d432ccecc8 (main) [!defined _POSIX_SOURCE]:
Use simpler "signal (sig, SIG_DFL)" rather than sigaction equivalent.
2004-04-20 15:10:07 +00:00
Jim Meyering 7b6892c3df (main): Rewrite signal-catching code to make it
similar to other coreutils programs.  When processing signals,
block all signals that we catch, but do not block signals that we
don't catch.  Avoid problems with unsigned int warnings.

(sighandler) [defined SA_NOCLDSTOP]:
Use simpler "signal (sig, SIG_DFL)" rather than sigaction equivalent.
2004-04-20 15:08:57 +00:00
Jim Meyering 31ef15a49f (sigill_handler, isaac_seed_machdep): Use void, not (obsolete) RETSIGTYPE. 2004-04-20 15:05:40 +00:00
Jim Meyering bb5a8d159c (main) [!defined _POSIX_SOURCE]:
Use simpler "signal (sig, SIG_IGN)" rather than sigaction equivalent.
2004-04-20 10:44:42 +00:00
Jim Meyering 3d286f8c91 . 2004-04-20 10:18:48 +00:00
Jim Meyering d3cb92f9b8 Don't include pathmax.h; system.h already does it. 2004-04-20 09:34:43 +00:00
Jim Meyering 50469e2c80 . 2004-04-20 09:21:30 +00:00
Jim Meyering ffccc03ad8 (cut_fields): Free buffer upon getndelim2 failure. 2004-04-20 06:50:37 +00:00
Jim Meyering 9b10f9414f (isaac_seed_start) [AVOID_USED_UNINITIALIZED_WARNINGS]:
Initialize a buffer to avoid warnings from tools like valgrind.
2004-04-19 20:07:25 +00:00
Jim Meyering 332853e722 . 2004-04-19 18:58:24 +00:00
Jim Meyering af719b0318 Make pwd work even if the resulting name is so long that getcwd fails.
(path_free, path_init, path_prepend): New functions.
(nth_parent, find_dir_entry, robust_getcwd): New functions.
(main): First try getcwd, then, upon failure, robust_getcwd.
2004-04-19 15:12:31 +00:00
Jim Meyering 6bb27087a1 (print_user): Use xrealloc here, rather than unchecked realloc.
Remove anachronistic casts.
2004-04-18 15:02:49 +00:00
Jim Meyering 544a43b5f7 (full_filename_): Don't leak upon failed realloc. 2004-04-18 14:58:51 +00:00
Jim Meyering d1932b917a (readdir_ignoring_dotdirs): Move function to system.h, renaming it. Update uses. 2004-04-18 13:14:25 +00:00
Jim Meyering de48260615 (readdir_ignoring_dot_and_dotdot): New inline function, from remove.c. 2004-04-18 13:09:27 +00:00
Jim Meyering 58127401f1 (add_file_name): Declare function to be `static'. 2004-04-17 14:05:37 +00:00
Jim Meyering c283745f2e (ds_init, ds_free): Declare functions to be `static'. 2004-04-17 14:01:56 +00:00
Jim Meyering 53a258fa4a (string_to_join_field): Declare function to be `static'. 2004-04-17 14:00:20 +00:00
Jim Meyering 65816f395e Include getpagesize.h.
(main): Align I/O buffers to page boundaries.
2004-04-15 10:52:04 +00:00
Jim Meyering 0adee504ff Include getpagesize.h.
(dopass): Align I/O buffers to page boundaries.
2004-04-15 10:50:07 +00:00
Jim Meyering e28e19cbba Include getpagesize.h.
(copy_reg): Align I/O buffers to page boundaries.
2004-04-15 10:37:59 +00:00
Jim Meyering 0c40916e6f (gcd, lcm, ptr_align): New functions, moved from od.c. 2004-04-15 09:12:25 +00:00
Jim Meyering 1365b2f708 (gcd, lcm): Remove; now in system.h. 2004-04-15 09:12:01 +00:00
Jim Meyering a5d9418d66 (ROUND_UP_OFFSET, PTR_ALIGN): Remove.
All uses replaced by ptr_align.
2004-04-15 09:11:42 +00:00
Jim Meyering 5f20d9e921 Include getpagesize.h.
(main): Align I/O buffers to page boundaries.
2004-04-15 09:10:54 +00:00
Jim Meyering 7c22ac2383 . 2004-04-14 08:43:32 +00:00
Jim Meyering 907e43cc4a . 2004-04-12 09:39:24 +00:00
Jim Meyering 4ed4732e78 Include "utimecmp.h".
(copy_internal): Compare time stamps using utimecmp rather than
MTIME_CMP.
2004-04-12 09:30:57 +00:00
Jim Meyering 8309aea61e Include stat-macros.h, not file-type.h.
Move more definitions into stat-macros.h.
2004-04-09 12:05:45 +00:00
Jim Meyering b9c4b346f1 undo last change 2004-04-09 12:03:02 +00:00
Jim Meyering b29e52796a Don't include "file-type.h", now that system.h does. 2004-04-09 08:26:17 +00:00
Jim Meyering e357aa96a4 Include file-type.h rather than hard-coding all
of its macros definitions -- the list was slightly out of date.
2004-04-09 08:25:32 +00:00
Jim Meyering 7c7a16a2d8 (O_NOCTTY): Remove redundant decl. 2004-04-08 21:36:18 +00:00
Jim Meyering 9f478111bf (flags, usage): Remove noctty flag.
(main): Always use O_NOCTTY when opening files.
2004-04-08 21:36:06 +00:00
Jim Meyering 82024e9938 (set_fd_flags): Undo part of today's change: it's a little
cleaner -- and more efficient in the common case -- to go
ahead and OR in the -1 when fcntl fails.
2004-04-08 21:30:18 +00:00
Jim Meyering 1af4fd3a54 (dd_copy): Mark two diagnostics for translations. 2004-04-08 21:26:28 +00:00
Jim Meyering a61bca91eb . 2004-04-08 15:38:59 +00:00
Jim Meyering d56fd78b42 (dd_LDADD, shred_LDADD): Add fdatasync's lib. 2004-04-08 15:36:31 +00:00
Jim Meyering 10629f7e88 Correct spelling: s/shasum/sha1sum. 2004-04-08 15:31:08 +00:00
Jim Meyering 2a888f75af (LONGEST_SYMBOL): Tweak comment. 2004-04-08 15:25:39 +00:00
Jim Meyering 470a15a00e (set_fd_flags): Don't OR in -1 when fcntl fails.
Rename parameter, flags, to avoid shadowing global.
2004-04-08 15:20:33 +00:00
Jim Meyering 0c5fbdba06 New dd conv= symbols nocreat, excl, fdatasync, fsync,
and new dd options iflag= and oflag=.

(usage): Document.
(fdatasync) [!HAVE_FDATASYNC]: New macro.
(C_NOCREAT, C_EXCL, C_FDATASYNC, C_FSYNC): New macros.
(input_flags, output_flags): New vars.
(LONGEST_SYMBOL): New macro.
(struct symbol_value): Renamed from struct conversion.  Members
symbol and value renamed from convname and conversion.  The
symbol value is now an array instead of a pointer; this saves
a bit of space and time in practice.  All uses changed.
(conversions): Add nocreat, excl, fdatasync, fsync.  Now const.
(flags): New constant array.
(iflag_error_msgid, oflag_error_msgid): New constants.
(parse_symbols): Renamed from parse_conversion and generalized
to handle either conversion or flag symbols.
(scanargs): Adjust uses of parse_symbols accodingly.  Add
support for iflag= and oflag=.  Reject attempts to use
both excl and nocreat.
(set_fd_flags): New function.
(dd_copy): Just return X rather than calling quit (X), since our
caller invokes quit with the returned value.  Add support for
fdatasync and fsync.
(main): Add support for iflags=, oflags=, and new conv= symbols.
2004-04-08 10:22:05 +00:00