Mercurial > vordog
changeset 4:5fa5e5199d1a
use basename of binary file in messages.
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Tue, 08 Jul 2008 12:21:12 +0800 |
parents | 60a234c9c03f |
children | e59963b503cb |
files | vd_watchdog/vd_watchdog.c |
diffstat | 1 files changed, 9 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/vd_watchdog/vd_watchdog.c Tue Jul 08 12:13:58 2008 +0800 +++ b/vd_watchdog/vd_watchdog.c Tue Jul 08 12:21:12 2008 +0800 @@ -26,15 +26,18 @@ #include <stdio.h> #include <stdlib.h> #include <unistd.h> +#include <string.h> #include <fcntl.h> #include <sys/ioctl.h> #include <sys/types.h> +#include <libgen.h> #include "vordog.h" #define DEVNAME "/dev/vordog0" -#define PROG "vd_watchdog" +#define PROG prog static int unit_factors[] = {0, 1, 60, 3600}; +static const char *prog = NULL; static void watchdog(int timeout, int unit) { @@ -119,7 +122,9 @@ main(int argc, char * const argv[]) { int timeout, unit; int ch; - const char *prog = argv[0]; + + prog = basename(argv[0]); /* name of binary file. */ + prog = strdup(prog); timeout = 30; /* default: 30s */ unit = VDT_1S; @@ -162,5 +167,7 @@ daemonize(); watchdog(timeout, unit); + + free((void *)prog); return 0; }