From fe466f1d1e460d25d92db30a38cef8bf12e5adab Mon Sep 17 00:00:00 2001 From: Carson Fleming Date: Thu, 27 Aug 2026 00:25:38 -0400 Subject: yup it's 25 lines of code love to see it --- .gitignore | 1 + README | 19 +++++++++++++++++++ forkit.c | 24 ++++++++++++++++++++++++ makefile | 8 ++++++++ 4 files changed, 52 insertions(+) create mode 100644 .gitignore create mode 100644 README create mode 100644 forkit.c create mode 100644 makefile diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..567609b --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +build/ diff --git a/README b/README new file mode 100644 index 0000000..6a27167 --- /dev/null +++ b/README @@ -0,0 +1,19 @@ +forkit +______ + +This is slightly more convenient than: +```bash +nohup whatever &>/dev/null /dev/null +#include + +int main (int argc, char** argv) { + if (argc < 2) { + fprintf(stderr, "forkit: give something to fork\n"); + return 1; + } + + pid_t child_pid = fork(); + if (child_pid < 0) { + perror("forkit"); + return 1; + } + + if (child_pid > 0) { + printf("forkit: great success\n"); + return 0; + } + + execvp(argv[1], &argv[1]); + perror("forkit"); + return 1; +} diff --git a/makefile b/makefile new file mode 100644 index 0000000..b4994db --- /dev/null +++ b/makefile @@ -0,0 +1,8 @@ +all: + mkdir -p build + cc forkit.c -o build/forkit +install: + cp build/forkit /usr/local/bin + chmod 0755 /usr/local/bin/forkit +clean: + rm -rf build -- cgit v1.2.3