commit 08feb3e1568073bdbf9a17192586950afcdcabbe
parent 84e854c17318ef0af147482124cb430b3f7ed6c5
Author: Ari Malinen <ari.malinen@gmail.com>
Date: Fri, 25 Jul 2014 21:19:42 +0300
Check daemon() return value
Diffstat:
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/crond.c b/crond.c
@@ -463,7 +463,10 @@ main(int argc, char *argv[])
if (nflag == 0) {
openlog(argv[0], LOG_CONS | LOG_PID, LOG_CRON);
- daemon(1, 0);
+ if (daemon(1, 0) != 0) {
+ logerr("error: failed to daemonize %s\n", strerror(errno));
+ return EXIT_FAILURE;
+ }
if ((fp = fopen(pidfile, "w"))) {
fprintf(fp, "%d\n", getpid());
fclose(fp);