diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2020-04-18 22:36:27 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2020-04-18 22:36:27 +0300 |
commit | 84838fa69592cf37f97aaa918ad4e69b8bd4d62a (patch) | |
tree | 1f0395d1ff3f5ad391155bcd819ee77b972eb02f /src/pidfile.c | |
parent | 5e93c56acf080ef006176076be4efab4aa0591c0 (diff) | |
download | wydawca-84838fa69592cf37f97aaa918ad4e69b8bd4d62a.tar.gz wydawca-84838fa69592cf37f97aaa918ad4e69b8bd4d62a.tar.bz2 |
Modify pidfile functions
Diffstat (limited to 'src/pidfile.c')
-rw-r--r-- | src/pidfile.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/pidfile.c b/src/pidfile.c index edd8e09..efd2f80 100644 --- a/src/pidfile.c +++ b/src/pidfile.c @@ -20,13 +20,13 @@ char *pidfile = LOCALSTATEDIR "/run/wydawca.pid"; int force_startup; void -remove_pidfile(void) +pidfile_remove(void) { unlink(pidfile); } void -check_pidfile() +pidfile_check(void) { FILE *fp = fopen(pidfile, "r+"); @@ -60,7 +60,7 @@ check_pidfile() strerror(errno)); exit(EX_UNAVAILABLE); } else { - fp = fopen(pidfile, "w"); + fp = fopen(pidfile, "w"); if (!fp) { wy_log(LOG_ERR, _("cannot open pidfile %s for writing: %s"), @@ -71,3 +71,17 @@ check_pidfile() fprintf(fp, "%lu\n", (unsigned long) getpid()); fclose(fp); } + +void +pidfile_update(void) +{ + FILE *fp = fopen(pidfile, "w"); + if (!fp) { + wy_log(LOG_ERR, + _("cannot open pidfile %s for writing: %s"), + pidfile, strerror(errno)); + exit(EX_UNAVAILABLE); + } + fprintf(fp, "%lu\n", (unsigned long) getpid()); + fclose(fp); +} |