4 /* strerror, and errno family.. */
10 /** Number of processes to spawn */
11 #define PROCESS_NUMBER 3
14 * Processes to spawn (programs to be execl'ed)
16 char * processes[PROCESS_NUMBER] = {
23 * Bootstrap program used for starting all three main processes.
27 * Variable storing Process ID. In our case we need only to check if
28 * it's equal 0, to exec new program.
32 /** Index of the current process to spawn. */
35 /** Error (theoretically) returned by execl. */
38 for (; i < PROCESS_NUMBER; i++) {
39 fprintf(stderr, "[%s] Forking process %d\n", "bootstrap", i);
42 /* If it is child fork */
44 fprintf(stderr, "[%s] Forked process %d has id: %d\n", "bootstrap", i, getpid());
47 * Create new session for this process, so it won't close
48 * after the parent process exit.
51 err = execl(processes[i], NULL);
54 * According to manual, this will only occur
55 * if there was an error in execl
58 fprintf(stderr, "[%s] Something went wrong when spawning %s. Error: %s\n",
59 "bootstrap", processes[i], strerror(errno));
62 /* There was an error when forking */
64 fprintf(stderr, "[%s] Something went wrong when forking %s. Error: %s\n",
65 "bootstrap", processes[i], strerror(errno));
70 /* All processes should be now spawned. Close bootstrap program. */