Commit Graph

49 Commits

Author SHA1 Message Date
Sami Kerola
52269d22f3 all: check stdout and stderr status at exit
If stream status is not checked at the end of execution below problem
would not report error, or non-zero exit code.  The uptime is just an
example same was true with all commands of the project.

$ uptime >&- ; echo $?
uptime: write error: Bad file descriptor
1
$ uptime >/dev/full ; echo $?
uptime: write error: No space left on device
1

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-03-23 15:57:53 +01:00
Sami Kerola
85e0a23347 watch: refactor code, add output_header() and run_command()
The main() was starting to be quite long with deep indents.  Both
signs of clean up being welcome change.

FIXME: The comment also changes -g option to exit immediately,
when screen contents change.  This should be separated commit,
e.g. the stuff is not ready to be merged.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-03-16 14:32:49 +01:00
Sami Kerola
dbedc905fe watch: remove arbitrary terminal size restriction
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-03-16 13:18:57 +01:00
Sami Kerola
94fa402d4b slabtop, vmstat, watch: remove file descriptor constants
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-03-16 13:18:43 +01:00
Kent R. Spillner
ddfc402886 Don't check if output changed on first screen.
When invoked with the --chgexit/-g options wait until we have at
least one screen of output before checking if the output changed.
Otherwise, we're comparing the initial screen of output to all
spaces, which usually isn't what we want.
2012-03-11 10:14:27 -05:00
Kent R. Spillner
f5a3afdcae watch: exit cleanly when falling through main loop.
Revert commit ffe5e0b08e.  Restores
clean exit when falling through main loop.

Previously, watch only exited when there was an error or when
interrupted by the user.  Commit 81f64657ba
added another exit condition when the watched command's output
changes, causing execution to fall out of the main loop.

With this change, watch correctly restores the terminal and returns
an exit code indicating success when invoked with the --chgexit/-g
options.
2012-03-10 18:35:08 -06:00
Sami Kerola
ce61089059 docs: clarification to license headers in files
Add license header to all files.  The summary of licensing is below,
taken from Craig Small's email which is referred in commit message
tail.

sysctl and pgrep are GPL 2+
The rest is LGPL 2.1+

Reference: http://www.freelists.org/post/procps/Incorrect-FSF-address-in-the-license-files,8
Bug-Redhat: https://bugzilla.redhat.com/show_bug.cgi?id=797962
CC: Craig Small <csmall@enc.com.au>
CC: Jaromir Capik <jcapik@redhat.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-03-03 18:41:11 +11:00
Sami Kerola
703e1e0486 watch: remove unused variables
watch.c:281:43: warning: unused variable 'option_version' [-Wunused-variable]
watch.c:281:26: warning: unused variable 'option_help' [-Wunused-variable]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>

Conflicts:

	watch.c
2012-03-03 18:31:13 +11:00
Craig Small
35d6960b5a Merge commit 'refs/merge-requests/1' of git://gitorious.org/procps/procps 2012-03-03 14:39:43 +11:00
Sami Kerola
529fa2e615 watch: inform about optional argument for -d switch
The -d, --differences switch(s) can use optional argument that was
not documented earlier.

Reported-By: Marian Sigler <m@qjym.de>
Bug-Debian: http://bugs.debian.org/597021
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-02-11 21:43:28 +01:00
Sami Kerola
ffe5e0b08e watch: remove unreachable code
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-02-05 20:48:33 +01:00
Kent R. Spillner
81f64657ba watch: exit when command output changes.
Add new flags to watch (-g/--chgexit) so that it exits when the
output changes.  This is useful in builds and shell scripts, for
example when deploying webapps to block the remainder of the
deployment steps until after the webapp starts.

e.g. watch --chgexit curl http://foo/bar
2012-01-26 08:42:37 -06:00
Mike Frysinger
13d8cc0681 watch: include sys/wait.h for waitpid
Fixes build warning:
	watch.c:682:3: warning: implicit declaration of
		function 'waitpid' [-Wimplicit-function-declaration]

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2012-01-24 08:55:05 +01:00
Sami Kerola
79ceb30b5c ps: unify cases and remove trailing dots in messages
Strings with lower caps & no trailing dots have greater change to
have multiple occurences, meaning less effort for translators, than
strings with them.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-01-15 20:52:58 +01:00
Jim Warner
f865ccbff9 watch: correct differences option, eliminate duplicate help text 2012-01-05 10:07:08 +11:00
Sami Kerola
7ac61b3fa1 watch: halt screen at exit on error
This change allows user to see what was the last message before exit
on error, and when where the last update.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-01-05 09:58:24 +11:00
Sami Kerola
21b5980f82 watch: include strutils.h
Without the header strtod_or_err() returned random value.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-01-05 09:58:19 +11:00
Craig Small
f776e59123 fixed e and x options in watch
The -e option would print a confusing error message. This is because
most error messages in watch are one word.  This fix makes a more
sensible message about what went wrong.

The -x option exited before the endwin() function was called, so if the
child process died the terminal was left in a funky state. endwin is now
called just before the exit(8) for the -x option.
2012-01-04 09:18:16 +11:00
Craig Small
fb11e1fe0a Changed the err and warns to macros
err and warn are BSD format but they are not recommended by library
developers.  However their consiseness is useful!

The solution is to use some macros that create xerr etc which then
just map to the error() function.  The next problem is error() uses
program_invocation_name so we set this to program_invovation_short_name

This is a global set but seems to be the convention (or at least errors
are on the short name only) used everywhere else.
2012-01-03 18:48:43 +11:00
Sami Kerola
c3405fab1a translations: group usage texts
Reference: http://www.freelists.org/post/procps/backporting,5
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-01-02 16:29:03 +11:00
Sami Kerola
5862f47b96 watch: use strtod_or_err() to validate user input
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-12-20 17:30:55 +01:00
Sami Kerola
0022b6ec5d nls: improve translations and provide translator help comments
Reference: http://www.freelists.org/post/procps/backporting,1
Reported-by: Jim Warner <james.warner@comcast.net>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-12-20 17:30:54 +01:00
Sami Kerola
c862a4caa5 nls: add functions which take translations to be used
Add the following three functions to most of the commands.

setlocale (LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);

Reference: http://www.freelists.org/post/procps/backporting,1
Reported-by: Jim Warner <james.warner@comcast.net>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-12-20 17:30:53 +01:00
Sami Kerola
1ef14f4bf9 includes: add xalloc.h to unify memory allocations
The xalloc.h provides necessary error checking.

Signed-off-by: Jim Warner <james.warner@comcast.net>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-12-20 17:30:50 +01:00
Sami Kerola
f90e436b88 watch: add gettext support
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-12-20 17:18:25 +01:00
Sami Kerola
6dd092412f watch: new usage & fix coding style
Coding style fixed and more readable help output.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-12-20 17:17:01 +01:00
Craig Small
367b8bb616 Fixed watch 8 bit so its optional
You can make watch 8bit clean by using the configure option
--enable-watch8bit
2011-12-20 22:12:37 +11:00
Jarrod Lowe
8967f0fca3 watch: support unicode
A patch from Debian.

Bug-Debian: http://bugs.debian.org/240989
Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/procps/+bug/318221
Backported-by: Sami Kerola <kerolasa@iki.fi>
2011-12-19 21:57:09 +11:00
Anthony DeRobertis
0dbdb862b1 watch: add precision wait time option -p
A patch from Debian.

Bug-Debian: http://bugs.debian.org/183486
Reviewed-by: Craig Small <csmall@debian.org>
Backported-by: Sami Kerola <kerolasa@iki.fi>
2011-12-19 21:57:09 +11:00
Craig Small
39a2f5d717 watch: interpret ANSI color code sequences
A patch from Debian.

Bug-Debian: http://bugs.debian.org/129334
Backported-by: Sami Kerola <kerolasa@iki.fi>
2011-12-19 21:56:02 +11:00
Mordechai T. Abzug
db552d38bc watch: add -exec and -beep flags and has better quoting
Additionally add -errexit flag (#183346).

A patch from Debian.

Bug-Debian: http://bugs.debian.org/410967
Bug-Debian: http://bugs.debian.org/183346
Reviewed-by: Craig Small <csmall@debian.org>
Backported-by: Sami Kerola <kerolasa@iki.fi>
2011-12-18 22:59:15 +11:00
Craig Small
b0ed746267 Watch uses unsigned chars to be 8bit clean
Taken from the Debian patch watch_8bitchar
2011-11-28 22:39:09 +11:00
Sami Kerola
17affc6637 watch.c: fix version printing
Print same style version string as other procps utilities. Also
the number makes now more sense, when it's coming from autotools
config.h

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-06-04 17:22:44 +02:00
albert
c0f3df30ca watch: tolerate umlauts 2007-05-28 03:18:52 +00:00
albert
d4a9781d4a avoid integer overflow for usleep() arg 2006-06-17 04:52:42 +00:00
albert
7767733812 dietlibc needs termios.h for struct winsize -- thanks Thomas Ogrisegg 2005-10-30 00:04:21 +00:00
albert
af2077f22d new /proc/vmstat fields 2004-08-27 14:23:36 +00:00
albert
8300609ba9 plenty -- see NEWS file and a diff 2004-07-15 01:17:15 +00:00
albert
1351592110 top: do not refresh like crazy 2003-03-17 23:42:00 +00:00
albert
7775a65c4d explains -t, --no-title #182246 2003-02-24 06:05:34 +00:00
albert
b8e27a1ecf watch -t 2003-02-09 07:27:16 +00:00
albert
3e67b58ec2 satisfy GPL section 2a and LGPL section 2b name+date requirement 2002-12-15 00:30:17 +00:00
albert
36ff49a29e the u arg, U arg, u key, and U key 2002-12-10 03:01:17 +00:00
albert
b657e7e08a NORETURN 2002-12-09 07:53:09 +00:00
albert
d614bf02e6 revert the Nov2002 c99 attempt 2002-11-28 23:09:48 +00:00
albert
bc60aa667d watch 'echo -e "A\n\nB"' 2002-11-28 19:47:16 +00:00
albert
7885375300 clean up code 2002-10-21 23:12:51 +00:00
csmall
e4c67b2724 Put most of the Debian patches in
added a lot of cvsignore files
2002-02-01 23:40:38 +00:00
csmall
03a9b5a30f procps 010114 2002-02-01 22:47:29 +00:00