diff options
author | June McEnroe <june@causal.agency> | 2020-08-15 14:46:11 -0400 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2020-08-15 14:54:33 -0400 |
commit | 34c39437f2bc2045a7017230dca7179faee5b4e6 (patch) | |
tree | b3d2f61035e3a153ea77308cf0563ec0a21b6e9c /daemon.h | |
parent | Implement non-blocking line-buffered reading (diff) | |
download | catsit-34c39437f2bc2045a7017230dca7179faee5b4e6.tar.gz catsit-34c39437f2bc2045a7017230dca7179faee5b4e6.zip |
Read service pipes
Changed line reading functions to return const char * because modifying the strings by adding '\0' into them screws up the following call.
Diffstat (limited to 'daemon.h')
-rw-r--r-- | daemon.h | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/daemon.h b/daemon.h index 7290420..17b1c7f 100644 --- a/daemon.h +++ b/daemon.h @@ -17,6 +17,7 @@ #include <errno.h> #include <grp.h> #include <pwd.h> +#include <stdbool.h> #include <stdint.h> #include <stdlib.h> #include <string.h> @@ -55,13 +56,13 @@ struct Line { char buf[512]; }; -static inline char *lineFlush(struct Line *line) { +static inline const char *lineFlush(struct Line *line) { if (!line->len) return NULL; line->buf[line->len++] = '\0'; return line->buf; } -static inline char *lineRead(struct Line *line, int fd) { +static inline const char *lineRead(struct Line *line, int fd) { char *nul = memchr(line->buf, '\0', line->len); if (nul) { nul++; @@ -131,6 +132,7 @@ void serviceStart(struct Service *service); void serviceStop(struct Service *service); void serviceRestart(struct Service *service); void serviceSignal(struct Service *service, int signal); +void serviceRead(struct Service *service); void serviceReap(pid_t pid, int status); extern char configError[]; |