8fd0ced
diff --git restorecond-2.7/restorecond.c restorecond-2.7/restorecond.c
8fd0ced
index f379db1..6fbbd35 100644
8fd0ced
--- restorecond-2.7/restorecond.c
8fd0ced
+++ restorecond-2.7/restorecond.c
8fd0ced
@@ -103,7 +103,10 @@ static int write_pid_file(void)
8fd0ced
 		pidfile = 0;
8fd0ced
 		return 1;
8fd0ced
 	}
8fd0ced
-	(void)write(pidfd, val, (unsigned int)len);
8fd0ced
+	if (write(pidfd, val, (unsigned int)len) != len) {
8fd0ced
+		syslog(LOG_ERR, "Unable to write to pidfile (%s)", strerror(errno));
8fd0ced
+		return 1;
8fd0ced
+	}
8fd0ced
 	close(pidfd);
8fd0ced
 	return 0;
8fd0ced
 }
8fd0ced
@@ -204,8 +207,10 @@ int main(int argc, char **argv)
8fd0ced
 	watch_file = server_watch_file;
8fd0ced
 	read_config(master_fd, watch_file);
8fd0ced
 
8fd0ced
-	if (!debug_mode)
8fd0ced
-		daemon(0, 0);
8fd0ced
+	if (!debug_mode) {
8fd0ced
+		if (daemon(0, 0) < 0)
8fd0ced
+			exitApp("daemon");
8fd0ced
+	}
8fd0ced
 
8fd0ced
 	write_pid_file();
8fd0ced