# HG changeset patch # User Thinker K.F. Li # Date 1215490872 -28800 # Node ID 5fa5e5199d1a1ffbb0c38fa208e2eb96e20222ad # Parent 60a234c9c03f8bf583a6f50365bda2940c2a5b2c use basename of binary file in messages. diff -r 60a234c9c03f -r 5fa5e5199d1a vd_watchdog/vd_watchdog.c --- 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 #include #include +#include #include #include #include +#include #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; }