diff options
author | Gary E. Miller <gem@rellim.com> | 2018-12-20 18:44:41 -0800 |
---|---|---|
committer | Gary E. Miller <gem@rellim.com> | 2018-12-20 18:44:41 -0800 |
commit | a8521d8b2af9a1423ba8aaf68b0baf20c887b017 (patch) | |
tree | c362bdeaf1923182dc673a2df3021c4b5ad9d52b /ntpshmmon.c | |
parent | bb625f98b24c9dd0f64b997da48fab96b243a8dc (diff) | |
download | gpsd-a8521d8b2af9a1423ba8aaf68b0baf20c887b017.tar.gz |
ntpshmmon: Fix program name to not include full path of program.
Diffstat (limited to 'ntpshmmon.c')
-rw-r--r-- | ntpshmmon.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/ntpshmmon.c b/ntpshmmon.c index 124ba3c9..21550ef8 100644 --- a/ntpshmmon.c +++ b/ntpshmmon.c @@ -35,7 +35,11 @@ int main(int argc, char **argv) int nsamples = INT_MAX; time_t timeout = (time_t)0, starttime = time(NULL); /* a copy of all old segments */ - struct shm_stat_t shm_stat_old[NTPSEGMENTS + 1];; + struct shm_stat_t shm_stat_old[NTPSEGMENTS + 1]; + char *whoami; + + /* strip path from program name */ + (whoami = strrchr(argv[0], '/')) ? ++whoami : (whoami = argv[0]); memset( shm_stat_old, 0 ,sizeof( shm_stat_old)); @@ -73,7 +77,7 @@ int main(int argc, char **argv) break; case 'V': (void)fprintf(stderr, "%s: version %s (revision %s)\n", - argv[0], VERSION, REVISION); + whoami, VERSION, REVISION); exit(EXIT_SUCCESS); default: /* no option, just go and do it */ @@ -104,7 +108,7 @@ int main(int argc, char **argv) */ setvbuf(stdout, NULL, _IOLBF, 0); - (void)printf("ntpshmmon version 1\n"); + (void)printf("%s: version %s\n", whoami, VERSION); if (offset) { (void)printf("# Name Offset Clock Real L Prc\n"); } else { |