summaryrefslogtreecommitdiffstats
path: root/tools/pidfile.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2012-11-30 12:57:26 +0100
committerRainer Gerhards <rgerhards@adiscon.com>2012-11-30 12:57:26 +0100
commit7182c6def360378038c9dc824b7cdf8f3d73a73f (patch)
tree703298652f45ac063837ae79a313e84abb0b21c0 /tools/pidfile.c
parent886ce6653dbc12937fdd80687b167e4323f59ce4 (diff)
downloadrsyslog-7182c6def360378038c9dc824b7cdf8f3d73a73f.tar.gz
rsyslog-7182c6def360378038c9dc824b7cdf8f3d73a73f.tar.bz2
rsyslog-7182c6def360378038c9dc824b7cdf8f3d73a73f.zip
silence compiler warnings
the changes do not affect actual code execution, just keep the compile log clean.
Diffstat (limited to 'tools/pidfile.c')
-rw-r--r--tools/pidfile.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/tools/pidfile.c b/tools/pidfile.c
index e9601232..8298b94e 100644
--- a/tools/pidfile.c
+++ b/tools/pidfile.c
@@ -55,7 +55,8 @@ int read_pid (char *pidfile)
if (!(f=fopen(pidfile,"r")))
return 0;
- fscanf(f,"%d", &pid);
+ if(fscanf(f,"%d", &pid) != 1)
+ pid = 0;
fclose(f);
return pid;
}
@@ -113,7 +114,8 @@ int write_pid (char *pidfile)
#if HAVE_FLOCK
if (flock(fd, LOCK_EX|LOCK_NB) == -1) {
- fscanf(f, "%d", &pid);
+ if(fscanf(f, "%d", &pid) != 1)
+ pid = 0;
fclose(f);
printf("Can't lock, lock is held by pid %d.\n", pid);
return 0;