Commit d4a9a1e5 authored by Craig Small's avatar Craig Small

watch: use sysconf() for hostname length

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.

 commit e564ddcb
parent 1a26eec1
......@@ -60,9 +60,6 @@
# define isprint(x) ( (x>=' '&&x<='~') || (x>=0xa0) )
#define HOST_NAME_MAX 64
/* Boolean command line options */
static int flags;
......@@ -380,7 +377,8 @@ static void output_header(char *restrict command, double interval)
char *ts = ctime(&t);
char *header;
char *right_header;
char hostname[HOST_NAME_MAX + 1];
int max_host_name_len = (int) sysconf(_SC_HOST_NAME_MAX);
char hostname[max_host_name_len + 1];
int command_columns = 0; /* not including final \0 */
gethostname(hostname, sizeof(hostname));
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment