--------------- Original Master Branch Commit Message:
Hurd doesn't have HOST_NAME_MAX, neither does Solaris.
An early fix just checked for this value and used 64 instead.
This change uses sysconf which is the correct method, possibly until
this compiles on some mis-behaving OS which doesn't have this value.
References:
commit e564ddcb01procps-ng/procps#54
Signed-off-by: Jim Warner <james.warner@comcast.net>
Reference(s):
proc/readproc.c: In function 'statm2proc'
proc/readproc.c:600:9: warning: variable 'num' set but not used [-Wunused-but-set-variable]
proc/stat.c: In function 'stat_derive_unique':
proc/stat.c:429:1: warning: no return statement in function returning non-void [-Wreturn-type]
ps/parser.c: In function 'arg_type':
ps/parser.c:1098:3: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
ps/parser.c:1099:34: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if'
lib/signals.c: In function 'strtosig':
lib/signals.c:243:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
lib/signals.c:245:13: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if'
slabtop.c: In function 'print_summary':
slabtop.c:223:29: warning: unused variable 'stats' [-Wunused-variable]
watch.c: In function 'process_ansi':
watch.c:232:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
watch.c:235:2: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if'
Signed-off-by: Jim Warner <james.warner@comcast.net>
If process_ansi encountered an unknown character when processing an ANSI
escape sequence, it would ungetc all the characters read so far, except
for the character just read, and the opening '\033['. ungetting the
middle of the escape sequence does not produce useful results, and also
relies on the unportable assumption that ungetc works on multiple
characters (which glibc does not support). Discard the characters
instead.
Signed-off-by: Josh Triplett <josh@joshtriplett.org>
process_ansi stopped processing an ANSI escape sequence if
(c < '0' && c > '9' && c != ';'), which will never happen. Fix the
range check to use || instead.
Signed-off-by: Josh Triplett <josh@joshtriplett.org>
process_ansi assumed all numbers in a color control sequence correspond
to colors or attributes, which breaks badly if it encounters a
ISO-8613-3 escape sequence (such as for truecolor RGB). For instance,
the sequence "\x1b[38;2;10;20;30m" sets the foreground color to
rgb(10,20,30), but watch will interpret all five numbers in the sequence
as colors or attributes themselves.
Stop processing the entire escape sequence if watch encounters any
number it doesn't understand, as that number may change the meaning of
the rest of the sequence.
As part of the fix to truncate the command in non-8bit, watch had
the function for output_header changed (much for scope cleanliness
and cohesiveness than anything; so I'm going to blame Meyer)...
Anyhow the 8bit enabled version did not have that update which
meant watch failed to compile. Thanks to @asavah for issue #37
and the patch.
References:
commit 5a40c7970d
Both watch and free used the locale to determine the required delay
interval for subsequent updates. It's preferable to not care about
locale and accept both 12.34 and 12,34 as meaning 12 seconds and
340 microseconds.
References:
https://bugs.debian.org/692113
Signed-off-by: Craig Small <csmall@enc.com.au>
When the screen width is not long enough to display the entire
command, watch puts three dots ... like elipses at the end of
the truncated line.
It's been like that for years, perhaps noone uses non 8-bit
watch?
References:
commit 367b8bb616
Signed-off-by: Craig Small <csmall@enc.com.au>
Commit 99fa7f removed watch crashing from having the null ANSI
sequence. However it just ignored that sequence instead of fixing it.
This change correctly checks buf (not undefined endptr) and sends
the reset attribute if found.
Closes: #12
[ but most definitely not all of them by a long shot ]
Reference(s):
proc/diskstat.c:186:17: warning: unused variable 'is_disk' [-Wunused-variable]
int retval, is_disk;
^
proc/namespace.c:110:1: warning: control may reach end of non-void function [-Wreturn-type]
}
^
proc/readproc.c:1131:50: warning: address of array 'ent->d_name' will always evaluate to 'true' [-Wpointer-bo
if(unlikely(unlikely(!ent) || unlikely(!ent->d_name))) return 0;
~~~~~~^~~~~~
proc/readproc.c:1158:50: warning: address of array 'ent->d_name' will always evaluate to 'true' [-Wpointer-bo
if(unlikely(unlikely(!ent) || unlikely(!ent->d_name))) return 0;
~~~~~~^~~~~~
proc/sysinfo.c:45:12: warning: unused variable 'stat_fd' [-Wunused-variable]
static int stat_fd = -1;
^
proc/sysinfo.c:49:12: warning: unused variable 'meminfo_fd' [-Wunused-variable]
static int meminfo_fd = -1;
^
proc/sysinfo.c:51:12: warning: unused variable 'vminfo_fd' [-Wunused-variable]
static int vminfo_fd = -1;
^
proc/sysinfo.c:53:12: warning: unused variable 'vm_min_free_fd' [-Wunused-variable]
static int vm_min_free_fd = -1;
^
proc/uptime.c:157:12: warning: unused variable 'realseconds' [-Wunused-variable]
time_t realseconds;
^
proc/uptime.c:158:16: warning: unused variable 'realtime' [-Wunused-variable]
struct tm *realtime;
^
vmstat.c:574:20: warning: format specifies type 'unsigned int' but the argument has type 'unsigned long' [-Wformat]
DSTAT(PROCPS_DISKSTAT_READ_TIME),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
vmstat.c:578:20: warning: format specifies type 'unsigned int' but the argument has type 'unsigned long' [-Wformat]
DSTAT(PROCPS_DISKSTAT_WRITE_TIME),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
watch.c:230:7: warning: variable 'endptr' is uninitialized when used here [-Wuninitialized]
if (*endptr == '\0') set_ansi_attribute(0); /* [m treated as [0m */
^~~~~~
Signed-off-by: Jim Warner <james.warner@comcast.net>
Previously the default background color was expected
to be always black and the default foreground color
was expected to be always white. This commit extends
the group of color pairs with pairs containing default
colors.
The previous code assumed that there would be 1 or 2 attributes to
apply. In fact, there can in general be any number (but typically
between 1 and 3). This commit generalizes the existing code to read
arbitrarily many attributes from the escape sequence.
Once the write side of the pipe has been duped to stdout for the child,
the original pipefd is no longer needed, so it can be closed to avoid
leaking to the child.
The leak can easily be seen with "watch ls -l /proc/self/fd", but I
found this due to "watch lvs" diagnosing itself:
File descriptor 4 (pipe:[3163616]) leaked on lvs invocation.
Signed-off-by: Josh Stone <jistone@redhat.com>
To assist translators, the help lines are split so that each translation
chunk has one option. This gives bonus of if we add or change an option,
only that option remains untranslated rather than the entire help block.
Reference:
http://www.freelists.org/post/procps/procpsng-for-Translation-Project,1
Signed-off-by: Craig Small <csmall@enc.com.au>
watch would only use an interval of up to 4294 seconds and silently
change to this limit. The 4294 seconds is 2^32/10^6 or how many
microseconds fit into unsigned int.
This change increases the limit to 2^32 seconds which is
approximately 136 years. This should be ok for now. Anything above
the old limit now uses sleep() instead of usleep() which only uses
integers (so 9999.123 seconds will be 9999 seconds)
This bug was first reported in 2006 and included a patch by
Stephen Kratzer. The patch was updated to fit the current source.
Bug-Debian: http://bugs.debian.org/720445
References: http://sourceforge.net/mailarchive/message.php?msg_id=4335929
Signed-off-by: Craig Small <csmall@enc.com.au>
For portabiliy, check for program_invocation_name during configure and
define HAVE_PROGRAM_INVOCATION_NAME accordingly. Use of this symbol is
now enclosed with the appropriate #ifdef block.
The symbol program_invocation_name is only used for error message
handling using error(), so it's safe to omit this if it is not
available.
watch.c:255:14: warning: no previous declaration for 'get_time_usec' [-Wmissing-declarations]
watch.c:303:6: warning: no previous declaration for 'output_header' [-Wmissing-declarations]
watch.c:364:5: warning: no previous declaration for 'run_command' [-Wmissing-declarations]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
The commit 8967f0fca3 has an typo like
error, which I must have done. The Bug-Debian 240989 did not have 12
but 128. Rest of the fixes are from Bug-Debian 675069 e.g. missing
include added, and usage of iswprint().
Bug-Debian: http://bugs.debian.org/240989
Bug-Debian: http://bugs.debian.org/675069
Reported-by: "Dr. David Alan Gilbert" <dave@treblig.org>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
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>
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>
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.
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.
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>
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
Fixes build warning:
watch.c:682:3: warning: implicit declaration of
function 'waitpid' [-Wimplicit-function-declaration]
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
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>
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>