diff options
author | Arthur de Jong <arthur@arthurdejong.org> | 2011-12-10 22:17:02 +0000 |
---|---|---|
committer | Arthur de Jong <arthur@arthurdejong.org> | 2011-12-10 22:17:02 +0000 |
commit | 0e707ad52f990aa951bced9a680d14d8162336f0 (patch) | |
tree | 73dd812177e37cffcd3fd553f076933f9f39cdf8 /nslcd | |
parent | 258681b99162321fdca0fa2565f687ad2312858d (diff) |
properly handle failures to truncate the pid file
git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/nss-pam-ldapd@1568 ef36b2f9-881f-0410-afb5-c4e39611909c
Diffstat (limited to 'nslcd')
-rw-r--r-- | nslcd/nslcd.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/nslcd/nslcd.c b/nslcd/nslcd.c index f7341e3..3f93c37 100644 --- a/nslcd/nslcd.c +++ b/nslcd/nslcd.c @@ -498,7 +498,11 @@ static void create_pidfile(const char *filename) log_log(LOG_ERR,"cannot lock pid file (%s): %s",filename,strerror(errno)); exit(EXIT_FAILURE); } - ftruncate(fd,0); + if (ftruncate(fd,0)<0) + { + log_log(LOG_ERR,"cannot truncate pid file (%s): %s",filename,strerror(errno)); + exit(EXIT_FAILURE); + } mysnprintf(buffer,sizeof(buffer),"%d\n",(int)getpid()); if (write(fd,buffer,strlen(buffer))!=(int)strlen(buffer)) { |