summaryrefslogtreecommitdiff
path: root/src/timeout.c
AgeCommit message (Collapse)Author
2014-01-02maint: update all copyright year number rangesBernhard Voelker
Run "make update-copyright", but then also run this, perl -pi -e 's/2\d\d\d-//' tests/sample-test to make that one script use the single most recent year number.
2013-11-27timeout: avoid unlikely issues with --kill-afterPádraig Brady
* src/timeout.c (cleanup): When calling settimeout() from this signal handler, ensure we don't call out to error() or gettext(), which are not async-signal-safe. Also reset the errno which may be cleared by settimeout().
2013-08-01doc: use semicolon instead of period in option descriptionsBenno Schulenberg
Also do not end option descriptions with a period, properly indent continuation lines, and make some tiny clarifications. * src/du.c (usage): Lowercase after semicolon. * src/ls.c (usage): Semicolons instead of periods, small rephrasing and two hyphens for clarity, proper indentation. * src/mktemp.c (usage): Semicolons and lowercase. * src/od.c (usage): Semicolons. * src/ptx.c (usage): Use the standard phrase, clarify default option. * src/setuidgid.c (usage): Properly indent continuation line. * src/split.c (usage): Semicolons, lowercase, no final period. * src/stat.c (usage): Semicolons, lowercase. * src/tail.c (usage): Proper indentation, one shorter rephrasing, semicolons, no final periods. * src/timeout.c (usage): Properly indent, semicolons, no final periods. Fixes http://bugs.gnu.org/14976
2013-01-26timeout: ensure a blocked SIGALRM from the parent is unblockedStephan Krempel
* src/timeout.c (unblock_signal): A new function to unblock a specified signal, or warn if not possible. (set_timeout): Ensure SIGALRM is unblocked before we setup the timer. * tests/misc/timeout-blocked.pl: A new test for the issue. * tests/local.mk: Reference the new test. * NEWS: Mention the fix. Fixes: http://bugs.gnu.org/13535
2013-01-23maint: define usage note about mandatory args centrallyBernhard Voelker
Each program with at least one long option which is marked as 'required_argument' and which has also a short option for that option, should print a note about mandatory arguments. Define that well-known note centrally and use it rather than literal printf/fputs, and add it where it was missing. * src/system.h (emit_mandatory_arg_note): Add new function. * src/cp.c (usage): Use it rather than literal printf/fputs. * src/csplit.c, src/cut.c, src/date.c, src/df.c, src/du.c: * src/expand.c, src/fmt.c, src/fold.c, src/head.c, src/install.c: * src/kill.c, src/ln.c, src/ls.c, src/mkdir.c, src/mkfifo.c: * src/mknod.c, src/mv.c, src/nl.c, src/od.c, src/paste.c: * src/pr.c, src/ptx.c, src/shred.c, src/shuf.c, src/sort.c: * src/split.c, src/stdbuf.c, src/tac.c, src/tail.c, src/timeout.c: * src/touch.c, src/truncate.c, src/unexpand.c, src/uniq.c: Likewise. * src/base64.c (usage): Add call of the above new function because at least one long option has a required argument. * src/basename.c, src/chcon.c, src/date.c, src/env.c: * src/nice.c, src/runcon.c, src/seq.c, src/stat.c, src/stty.c: Likewise.
2013-01-01maint: update all copyright year number rangesJim Meyering
Run "make update-copyright", but then also run this, perl -pi -e 's/2\d\d\d-//' tests/sample-test to make that one script use the single most recent year number.
2012-11-04timeout: add --preserve-status to always propagate the exit statusÁngel González
It's useful for commands that support running for an indeterminite amount of time, to not return a specific timeout exit status (124), and instead let the command handle the timeout signal and return a status for the work done so far. * doc/coreutils.texi (timeout invocation): Describe the new option. * src/timeout.c (preserve_status): A new global boolean to enable the --preserve-status behavior. (usage): Describe the new option. (main): Don't return EXIT_TIMEOUT of preserve_status is set. * tests/misc/timeout.sh: Add a test for the new option.
2012-09-24timeout: handle signals more transparentlyPádraig Brady
This was originally attempted in commit v8.12-117-g5a647a0, but reverted before release because of the unreliability of disabling core dumps using setrlimit() on Linux kernels. This new version instead uses prctl() where available to more reliably disable core dumps for the timeout process. * m4/jm-macros.m4: Define HAVE_SETRLIMIT and HAVE_PRCTL. * src/timeout.c (disable_core_dumps): A new function that disables coredumps using prctl or setrlimit if available. (main): If the child exited with a signal and we can disable core dumps, then raise that signal to the timeout process itself, so that callers may also see the signal status. Also print a message indicating when the monitored command dumped core, as that information is lost in the signal propagation through timeout.
2012-02-29doc: timeout: document the exit status when run with "-s KILL"Rodrigo Campos
* src/timeout.c (usage): Document the exit status for this case, in --help and thus in the man page. Word so that it covers both the -s9 and -k options. * doc/coreutils.texi (timeout invocation): Document the exit status for this case.
2012-01-22maint: quote 'like this' or "like this", not `like this'Paul Eggert
* doc/coreutils.texi (Formatting the file names): coreutils now quotes 'like this'. * man/help2man: * src/timeout.c (usage): Quote 'like this' in diagnostics. * HACKING, Makefile.am, NEWS, README, README-hacking, TODO, cfg.mk: * doc/Makefile.am, doc/coreutils.texi, m4/jm-macros.m4: * man/Makefile.am, man/help2man, src/Makefile.am, src/copy.h: * src/extract-magic, src/ls.c, src/pinky.c, src/pr.c, src/sort.c: * src/split.c, src/timeout.c, src/who.c, tests/dd/skip-seek-past-file: * tests/pr/pr-tests: Quote 'like this' in commentary. * cfg.mk (old_NEWS_hash): Update due to changed old NEWS.
2012-01-09maint: src/*.c: change remaining quotes (without embedded spaces)Jim Meyering
Run this (twice): git grep -E -l '`[^ ]+'\' src/*.c \ |xargs perl -pi -e 's/`([^ ]+'\'')/'\''$1/'
2012-01-09maint: convert `...' to '...' in --help outputJim Meyering
All affected lines end with \ or \n\, so run this command until it produces no new changes (4 times): git grep -E -l '`[^ ]+'\''.*\\' src \ |xargs perl -pi -e 's/`([^ ]+'\''.*\\)/'\''$1/'
2012-01-07maint: use new emit_try_help in place of equivalent fprintfJim Meyering
Run this command: perl -0777 -pi -e \ 's/fprintf \(stderr, _\("Try `%s --help.*\n.*;/emit_try_help ();/m'\ src/*.c
2012-01-01maint: update all copyright year number rangesJim Meyering
Run "make update-copyright".
2011-09-22timeout: handle implicitly created threadsPádraig Brady
On some systems like glibc on GNU/kFreeBSD, a thread is implicitly created when timer_settime() is used. This breaks our scheme to ignore signals we've sent ourselves. * src/timeout.c (send_sig): Change the scheme used to ignore signals we've sent ourselves, to a more robust but perhaps limited scheme of ignoring all signals of a certain type after we've sent that signal to the job. * NEWS: Mention the change in behavior.
2011-09-01timeout: fixup previous warning fixPádraig Brady
* src/timeout.c (settimeout): Fix the previous commit to test errno rather than the return value.
2011-09-01timeout: suppress a redundant warning on some systemsPádraig Brady
* src/timeout.c (settimeout): Don't warn about ENOSYS which is returned on OpenBSD 4.9 at least. Reported by Bruno Haible
2011-08-25timeout: revert signal propagation enhancementPádraig Brady
This effectively reverts the unreleased commit 5a647a05 * src/timeout.c (main): Don't propagate signals from the monitored process, as on Linux /proc/sys/kernel/core_pattern could still handle them and cause false reports against `timeout`
2011-07-25timeout: support sub-second timeoutsPádraig Brady
* src/timeout.c (settimeout): A new function to convert from a floating point duration and call alarm() or timer_settime() if that's available. (parse_duration): Return a double rather than unsigned int. (usage): Mention floating point is supported. (main): Pass the double to settimeout() rather than calling alarm() directly with the parsed int. (cleanup): Likewise. * doc/coreutils.texi (timeout invocation): Say floating point timeouts now supported, and mention the caveat with resolution. * bootstrap.conf: Include the timer-time gnulib module. * tests/misc/timeout-parameters: Add a test with nanoseconds. * NEWS: Mention the improvement.
2011-07-16timeout: treat seconds counts like 'sleep' doesPaul Eggert
Treat fractions as a request to round up to the next representable value, and treat out-of-range values as maximal ones. This is consistent with how "sleep" works. And this way, "timeout 999999999999999999d FOO" and "timeout 4.5 foo" are more likely to do what the user wants. * src/timeout.c: Include c-strtod.h and xstrtod.h, not xstrtol.h. (apply_time_suffix): Change it to the way sleep.c's time_suffix does things. Maybe this function (identical in both programs, other than its name) should be moved to a library? (parse_duration): Return a maximal value on overflow. Return unsigned int, not unsigned long. Allow fractions, which round up to the next integer value. * tests/misc/timeout-parameters: Adjust tests to match new behavior. Add a very large number.
2011-07-16Fix capiTalization in comments.Paul Eggert
2011-07-16* src/timeout.c (main): Use waitpid, not wait (Bug#9098).Paul Eggert
Reported by Andreas Schwab. * src/timeout.c (SA_RESTART): Define to 0 if not defined.
2011-07-16timeout: port to NonStop (Bug#9077)Paul Eggert
* src/timeout.c (SA_RESTART): Define to 0 if not defined. (main): Don't assume signal handling uses SA_RESTART.
2011-07-08timeout: handle signals more transparentlyPádraig Brady
* m4/jm-macros.m4: Define HAVE_SETRLIMIT. * src/timeout.c: If the child exited with a signal, raise that signal to the timeout process itself, so that callers may also see the signal status. Use setrlimit to disable core dumps for the timeout process, which would be generated by some signals.
2011-07-08timeout: support cascaded timeoutsPádraig Brady
* src/timeout.c (cleanup): Send signals directly to the child in case it has started its own process group (like a cascaded timeout command would for example). * test/misc/timeout-group: Add a test case. * NEWS: Mention the fix.
2011-07-08timeout: add --foreground to support interactive commandsPádraig Brady
Or more accurately, commands not started from the shell prompt, that are interactive, or need to receive Ctrl-C etc. from the terminal. * doc/coreutils.texi (timeout invocation): Document --foreground. * src/timeout.c (main): Set the foreground flag and don't create a separate group. (cleanup): Only send a signal directly to the monitored command when the foreground flag is set. (usage): Describe --foreground. * tests/misc/timeout-group: Add a new test. * tests/Makefile.am: Reference new test. NEWS: Mention the new option. Reported by Shay Shimony Analysis by Alan Curry Fix suggested by Paul Eggert
2011-06-09maint: remove unneeded includesPádraig Brady
Remove unneeded includes as reported by: http://code.google.com/p/include-what-you-use/ * src/cp-hash.c: Remove unused include. * src/dd.c: Likewise. * src/du.c: Likewise. * src/head.c: Likewise. * src/kill.c: Likewise. * src/ls.c: Likewise. * src/stdbuf.c: Likewise. * src/timeout.c: Likewise. * src/truncate.c: Likewise.
2011-05-24doc: add a missing space in timeout --helpStéphane Raimbault
* src/timeout.c (usage): Add a space to be consistent with other uses of "(the default)" in the documentation. Signed-off-by: Pádraig Brady <P@draigBrady.com>
2011-01-01maint: update all copyright year number rangesJim Meyering
Run "make update-copyright".
2010-05-03maint: remove now-redundant definitions provided by sys/wait.hJim Meyering
* src/timeout.c (WIFSIGNALED, WTERMSIG): Remove definitions, now that gnulib guarantees they are defined in <sys/wait.h>. * src/operand2sig.c: Likewise. * src/kill.c: Likewise.
2010-04-24maint: remove now-unnecessary #if HAVE_header_H tests.Jim Meyering
* .x-sc_prohibit_always_true_header_tests: New file. * Makefile.am (syntax_check_exceptions): Add it. * src/cat.c: Remove #if HAVE_SYS_IOCTL_H test. * src/copy.c: Likewise. * src/ls.c: Likewise. * src/stty.c: Likewise. * src/install.c: Remove #if HAVE_SYS_WAIT_H test. * src/kill.c: Likewise. * src/operand2sig.c: Likewise. * src/timeout.c: Likewise. * src/pathchk.c: Remove #if HAVE_WCHAR_H test. * src/stat.c: Remove #if HAVE_NETINET_IN_H test.
2010-03-26timeout: use more standard option parsingKim Hansen
* src/timeout.c (main): Don't use parse_long_options() which is a helper for commands that don't have any long options specific to them. * tests/misc/timeout-parameters: Remove a case that now passes due to us accepting multiple instances of the --help and --version options. * THANKS: Add the author. Signed-off-by: Pádraig Brady <P@draigBrady.com>
2010-03-16timeout: add the --kill-after optionPádraig Brady
Based on a report from Kim Hansen who wanted to send a KILL signal to the monitored command when `timeout` itself received a termination signal. Rather than changing such a signal into a KILL, we provide the more general mechanism of sending the KILL after the specified grace period. * src/timeout.c (cleanup): If a non zero kill delay is specified, (re)set the alarm to that delay, after which a KILL signal will be sent to the process group. (usage): Mention the new option. Separate the description of DURATION since it's now specified in 2 places. Clarify that the duration is an integer. (parse_duration): A new function refactored from main(), since this logic is now called for two parameters. (main): Parse the -k option. * doc/coreutils.texi (timeout invocation): Describe the new --kill-after option and use @display rather than @table to show the duration suffixes. Clarify that a duration of 0 disables the associated timeout. * tests/misc/timeout-parameters: Check invalid --kill-after. * tests/misc/timeout: Check a valid --kill-after works. * NEWS: Mention the new feature.
2010-01-01maint: update all FSF copyright year lists to include 2010Jim Meyering
Use this command: git ls-files | grep -v COPYING \ | xargs env UPDATE_COPYRIGHT_USE_INTERVALS=1 \ build-aux/update-copyright
2009-12-08timeout: fix failure if timeout's parent has ignored SIGCHLDPádraig Brady
* src/timeout.c (main): Reset the SIGCHLD handler to the default as otherwise wait() could return -1 and set errno to ECHILD. This condition was ignored until commit 0b1dcf33, on 31-08-2009, "timeout: defensive handling of all wait() errors" but subsequently timeout would run the command correctly but then fail with an error message. * tests/misc/timeout: In a subshell set the CHLD handler to SIG_IGN to ensure the timeout command resets it to SIG_DFL. * NEWS: Mention the fix.
2009-10-25timeout: don't orphan monitored programs if they ignore specified signalsPádraig Brady
* src/timeout.c (install_signal_handlers): Handle any user specified signal, so that if it does not cause the child to exit then we don't exit and orphan the child. Previously this for example, would leave an orphan dd process running: timeout -sUSR1 1s dd if=/dev/zero of=/dev/null * NEWS: Mention the fix.
2009-10-08maint: move timeout exit statusesEric Blake
* src/timeout.c (EXIT_TIMEDOUT, EXIT_CANCELED): Remove as macros... * src/system.h (EXIT_TIMEDOUT, EXIT_CANCELED): ...and provide as enum values instead. * src/stdbuf.c (EXIT_CANCELED): Delete.
2009-09-21doc: mention the texinfo documentation in --helpPádraig Brady
* src/system.h: Rename emit_bug_reporting_address() to emit_ancillary_info() and update it to not print the translation project address in en_* locales, and _do_ print it in the 'C' (and other) locales so that it's included in the default man page. Also mention how to invoke the texinfo documentation for each command. Also move the "hard-locale.h" include to the 8 files that now use it. * man/help2man: Strip the newly added texinfo reference from the --help output as a more verbose version is already added by help2man. Suggestion from C de-Avillez
2009-09-14doc: improve timeout's --help messageJim Meyering
* src/timeout.c (usage): Improve --help description.
2009-09-01timeout: remove a redundant assignmentPádraig Brady
* src/timeout.c (main): While keeping argc and argv in sync may be marginally useful, it is redundant to update argc, so just remove that to suppress the clang warning.
2009-09-01timeout: defensive handling of all wait() errorsPádraig Brady
* src/timeout.c (main): Handle all possible cases of unexpected failures from wait(). This was prompted by the clang tool reporting the possible non-initialization of the status variable.
2009-08-25maint: remove Local Variables: indent-tabs-mode: nil from all sourcesJim Meyering
* src/getlimits.c: Likewise. * src/group-list.c: Likewise. * src/groups.c: Likewise. * src/mktemp.c: Likewise. * src/setuidgid.c: Likewise. * src/stdbuf.c: Likewise. * src/timeout.c: Likewise. * src/truncate.c: Likewise. * gl/lib/mbsalign.c: Likewise. * tests/test-lib.sh: Likewise. * bootstrap: Likewise. * README-hacking: Likewise.
2009-06-23maint: update all Copyright year lists to include 2009Jim Meyering
2009-06-13diag: say "failed to...", rather than "cannot..." in a few diagnosticsJim Meyering
* src/chroot.c (main): ...it's more precise. * src/nohup.c (main): Likewise. * src/setuidgid.c (main): Likewise. * src/timeout.c (main): Likewise.
2009-04-07maint: Clarify ambiguous refs to Linux kernels or GNU/Linux systemsPádraig Brady
* README-prereq: s_linux_GNU/Linux_ or s_linux_Linux kernel_ * README-valgrind: ditto * src/chown-core.c: ditto * src/dd.c: ditto * src/df.c: ditto * src/ls.c: ditto * src/mv.c: ditto * src/pwd.c: ditto * src/remove.c: ditto * src/shred.c: ditto * src/stat.c: ditto * src/su.c: ditto * src/system.h: ditto * src/timeout.c: ditto * src/truncate.c: ditto
2008-12-23timeout: remove problematic castsPádraig Brady
* src/timeout.c (apply_time_suffix): Change input parameter from unsigned int to unsigned long, which is the type of the variable it's actually manipulating. This removes the need for the cast which was giving a warning with the gcc options: -fstrict-aliasing -Wstrict-aliasing. Also add a check for overflow possible on 16-bit platforms, and fix indents. (main): Remove a redundant cast in the alarm() call.
2008-12-21build: add configure-time --enable-gcc-warnings option; avoid warningsJim Meyering
* bootstrap.conf (gnulib_modules): Add "warnings" module. * configure.ac: Add --enable-gcc-warnings, derived from code in bison. * src/Makefile.am (AM_CFLAGS): Set to $(WARN_CFLAGS) # $(WERROR_CFLAGS) * lib/Makefile.am (AM_CFLAGS): Change spelling to $(WARN_CFLAGS) Don't use $(WERROR_CFLAGS), yet. * src/system.h (usage): Declare. * src/base64.c (usage): Declare to be global, for consistency. * src/timeout.c (usage): Likewise. * src/truncate.c (usage): Likewise. * src/getlimits.c (usage): Likewise. * src/pinky.c (ttyname): Declare with prototype, rather than an empty argument list. * src/who.c (ttyname): Likewise. * src/su.c (crypt, getusershell, setusershell, endusershell): Likewise.
2008-10-03timeout.c: don't use perror; exit 125 upon failed forkJim Meyering
* src/timeout.c (main): Use "error", not perror. Elbert Pol noticed a build failure on OS/2. * src/timeout.c (main): Exit 125 (not errno) upon failed fork. Make the failed fork diagnostic match the one from install.c.
2008-08-26use new global, "Version", rather than macro, VERSIONJim Meyering
With this change, a version-string update no longer forces recompilation of 100+ src/*.o files. * src/version.c (Version): New global. New file. * src/version.h: Declare it. * src/Makefile.am: Put it in a library that everyone links to. (noinst_LIBRARIES, libver_a_SOURCES): Define. (LDADD): Add libver.a. (sc_tight_scope): Use perl (was sed), and a more relaxed regexp to build the global-variable-name-recognizing regexp list. * src/system.h: Include "version.h". (case_GETOPT_VERSION_CHAR): Use Version rather than VERSION. * src/basename.c (main): Use Version rather than VERSION. * src/chroot.c (main): Likewise. * src/cksum.c (main): Likewise. * src/dd.c (main): Likewise. * src/dirname.c (main): Likewise. * src/echo.c (main): Likewise. * src/hostid.c (main): Likewise. * src/hostname.c (main): Likewise. * src/link.c (main): Likewise. * src/logname.c (main): Likewise. * src/nice.c (main): Likewise. * src/nohup.c (main): Likewise. * src/printenv.c (main): Likewise. * src/printf.c (main): Likewise. * src/pwd.c (main): Likewise. * src/setuidgid.c (main): Likewise. * src/sleep.c (main): Likewise. * src/sync.c (main): Likewise. * src/test.c (main): Likewise. * src/timeout.c (main): Likewise. * src/true.c (main): Likewise. * src/tsort.c (main): Likewise. * src/unlink.c (main): Likewise. * src/uptime.c (main): Likewise. * src/users.c (main): Likewise. * src/whoami.c (main): Likewise. * src/yes.c (main): Likewise.
2008-07-30* timeout.c: Fix grammar in a comment. Normalize comment syntax.Jim Meyering