init.c provides a small C library and CLI for registering named commands as persistent startup entries using only classic OS startup filesystem primitives. Applications can register a command under a name, execute it immediately, list registrations, and remove them.
On POSIX, init.c writes executable scripts to /etc/init.d/ and creates S99 symlinks in /etc/rc{2,3,4,5}.d/. On Windows, it creates .cmd launchers in the user Startup folder and optionally adds a HKCU\...\Run registry entry. Registration metadata is stored under ~/.local/share/init/ on Linux and %APPDATA%\init\ on Windows. The CLI is implemented on top of libinit.
Register a startup command:
init myapp /usr/local/bin/myapp --daemonExecute the registered command immediately:
init myappList all registrations:
init --listList one registration:
init myapp --listRemove a registration:
init myapp --delete| Command/Flag | Description |
|---|---|
<name> <cmd> |
Register or replace a startup entry. |
<name> -d, <name> --delete |
Remove a registration if it exists. |
<name> -l, <name> --list |
List one registration if it exists. |
-l, --list |
List all registrations as name<TAB>path. |
<name> |
Execute the registered command immediately. |
-h, --help |
Show help and usage. |
-v, --version |
Show version. |
#include "init.h"
kc_init_t *ctx = kc_init_open();
kc_init_update(ctx, "app", "/usr/local/bin/app --daemon");
kc_init_list(ctx, "app");
kc_init_exec(ctx, "app");
kc_init_delete(ctx, "app");
kc_init_close(ctx);kc_init_open()- resolves metadata state and returns a context owned by the caller.kc_init_update()- registers or replaces a named startup command.kc_init_exec()- executes the registered command immediately.kc_init_list()- lists all registrations or one named registration.kc_init_delete()- removes a named registration and its startup artifacts.kc_init_path()- returns the resolved metadata directory for diagnostics.kc_init_close()- releases the context.
kc_init_updaterequires write access to/etc/init.d/and/etc/rc*.d/on Linux, which typically requires root.kc_init_execreads from the user metadata directory and does not require root.- No service managers, PID1 replacements, or external dependencies are used.
Compiled artifacts are generated under bin/{arch}/{platform}/ for the host architecture running the build.
make clean && makeThe project is prepared to build artifacts for multiple architectures under bin/{arch}/{platform}/. A plain make builds only the current host architecture, while the targets below build the full matrix or a specific target.
make all
make x86_64/linux
make x86_64/windows
make i686/linux
make i686/windows
make aarch64/linux
make aarch64/android
make armv7/linux
make armv7/android
make armv7hf/linux
make riscv64/linux
make powerpc64le/linux
make mips/linux
make mipsel/linux
make mips64el/linux
make s390x/linux
make loongarch64/linuxThis project is distributed under the GNU General Public License version 3 (GPLv3).
