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