module dummy; import c.stdlib; import c.std_lib; extern (C) { void someSignalFunction(int signal) { switch (signal) { case SIGQUIT: printf("I've been signaled with: SIGQUIT: PID: %i\n", getpid()); break; default: printf("Hey not my signal! I've been signaled with: %i\n", signal); } } } void childDameonProcess() { int result; printf("\nChild Starting\n"); for(int i; i < 1000000000; i++) {} // Now raise a signal(SIGQUIT) for our signalhandler function result = raise(SIGQUIT); for(int i; i < 1000000000; i++) {} printf("Child Exiting!\n"); } int main() { int forkPID; printf("Parent Starting\n"); signal(SIGQUIT, someSignalFunction); forkPID = fork(); if (forkPID > 0) printf("Child dameon started, Child PID:%i\n", forkPID); // Failed to spawn a new child process. if (forkPID < 0) printf("Dameon start failed!\n"); // Child has spwaned so continure loading the application code. if (forkPID == 0) { childDameonProcess(); // Child dameon code here return EXIT_SUCCESS; } printf("Parent Exiting\n"); return EXIT_SUCCESS; }