summaryrefslogtreecommitdiff
path: root/pullreqd.c
diff options
context:
space:
mode:
authormrb0nk500 <b0nk@b0nk.xyz>2021-06-04 10:09:47 -0400
committermrb0nk500 <b0nk@b0nk.xyz>2021-06-04 10:11:36 -0400
commit3c2d695e58a73f5d35a0dbc794b7d4b82a9841fe (patch)
tree339218392cea6f2a14023c76a980af6378e0c2db /pullreqd.c
parent852f24689ba9cfd989f1948dfbc8ab3a04430612 (diff)
Added `fork_proc()`.
Which handles forking a process, aswell as exiting the parent process.
Diffstat (limited to 'pullreqd.c')
-rw-r--r--pullreqd.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/pullreqd.c b/pullreqd.c
index 8161c8d..a690b3e 100644
--- a/pullreqd.c
+++ b/pullreqd.c
@@ -7,3 +7,17 @@
#include <sys/type.h>
#include <syslog.h>
#include <unistd.h>
+
+pid_t fork_proc() {
+ /* Fork off the parent. */
+ pid_t pid = fork();
+
+ /* The process id is non zero, so it must be the parent process. */
+ if (pid) {
+ /* Exit with EXIT_FAILURE if the parent's pid is
+ * negative, otherwise exit with EXIT_SUCCESS.
+ */
+ exit((pid < 0) ? EXIT_FAILURE : EXIT_SUCCESS);
+ }
+ return pid;
+}