Browse Source

Add faux_daemon() to header

Serj Kalichev 1 year ago
parent
commit
9bbb5dc097
2 changed files with 6 additions and 1 deletions
  1. 3 1
      faux/base/sys.c
  2. 3 0
      faux/faux.h

+ 3 - 1
faux/base/sys.c

@@ -43,10 +43,12 @@ bool_t faux_daemon(int nochdir, int noclose, const char *pidfile, mode_t mode)
 			if ((fd = open(pidfile,
 				O_WRONLY | O_CREAT | O_EXCL | O_TRUNC,
 				mode)) >= 0) {
+				ssize_t r = 0;
 				char str[20] = {};
 				snprintf(str, sizeof(str), "%u\n", pid);
 				str[sizeof(str) - 1] = '\0';
-				write(fd, str, strlen(str));
+				r = write(fd, str, strlen(str));
+				r = r; // Happy compiler
 				close(fd);
 			}
 		}

+ 3 - 0
faux/faux.h

@@ -106,6 +106,9 @@ bool_t faux_rm(const char *path);
 bool_t faux_mkdir_p(const char *path, mode_t mode);
 char *faux_expand_tilde(const char *path);
 
+// System
+bool_t faux_daemon(int nochdir, int noclose, const char *pidfile, mode_t mode);
+
 C_DECL_END
 
 #endif /* _faux_types_h */