aboutsummaryrefslogtreecommitdiffstats
path: root/src/daemon.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/daemon.h')
-rw-r--r--src/daemon.h39
1 files changed, 24 insertions, 15 deletions
diff --git a/src/daemon.h b/src/daemon.h
index dc8a355..1d4a747 100644
--- a/src/daemon.h
+++ b/src/daemon.h
@@ -67,21 +67,6 @@
*/
#define SAT_QUEUE 0
-/**
- * Command: remove jobs.
- */
-#define SAT_REMOVE 1
-
-/**
- * Command: print job queue.
- */
-#define SAT_PRINT 2
-
-/**
- * Command: run jobs.
- */
-#define SAT_RUN 3
-
/**
@@ -140,6 +125,22 @@ fail: \
FD = WANT
+#define PROLOGUE(USAGE_ASSUMPTION, ...) \
+ int state = -1; \
+ if (argc > 0) argv0 = argv[0]; \
+ if (!(USAGE_ASSUMPTION)) usage(); \
+ GET_FD(state, STATE_FILENO, open_state(__VA_ARGS__))
+
+#define CLEANUP_START \
+ errno = 0; \
+fail: \
+ if (errno) perror(argv[0]); \
+ if (state >= 0) close(state)
+
+#define CLEANUP_END \
+ return !!errno
+
+
/**
* Wrapper for `pread` that reads the required amount of data.
@@ -276,3 +277,11 @@ int dup2_and_null(int old, int new);
*/
int open_state(int open_flags, char **state_path);
+/**
+ * Let the daemon know that it may need to
+ * update the timers, and perhaps exit.
+ *
+ * @return 0 on success, -1 on error.
+ */
+int poke_daemon(void);
+