b2e6a184f23be9e5116bcdfa24eb186932701b4b
[citadel.git] / appimage / citadel.AppDir / ctdlvisor.c
1 #include <stdlib.h>
2 #include <unistd.h>
3 #include <stdio.h>
4 #include <sys/wait.h>
5
6
7
8
9 pid_t start_citadel() {
10         pid_t pid = fork();
11         if (pid == 0) {
12                 execlp("citserver", "citserver", "-x9", "-h/usr/local/citadel", NULL);
13                 exit(1);
14         }
15         else {
16                 return(pid);
17         }
18 }
19
20
21 pid_t start_webcit() {
22         pid_t pid = fork();
23         if (pid == 0) {
24                 execlp("/bin/bash", "bash", "-c", "sleep 7", NULL);
25                 exit(1);
26         }
27         else {
28                 return(pid);
29         }
30 }
31
32
33 pid_t start_webcits() {
34         pid_t pid = fork();
35         if (pid == 0) {
36                 execlp("/bin/bash", "bash", "-c", "sleep 9", NULL);
37                 exit(1);
38         }
39         else {
40                 return(pid);
41         }
42 }
43
44
45
46
47
48 main() {
49         int status;
50         pid_t who_exited;
51
52         pid_t citserver_pid = start_citadel();
53         //pid_t webcit_pid = start_webcit();
54         //pid_t webcits_pid = start_webcits();
55
56         do {
57                 printf("LD_LIBRARY_PATH = %s\n", getenv("LD_LIBRARY_PATH"));
58                 printf("PATH = %s\n", getenv("PATH"));
59
60
61                 printf("waiting...\n");
62                 who_exited = waitpid(-1, &status, 0);
63                 printf("pid=%d exited, status=%d\n", who_exited, status);
64
65                 if (who_exited == citserver_pid)        citserver_pid = start_citadel();
66                 //if (who_exited == webcit_pid)         webcit_pid = start_webcit();
67                 //if (who_exited == webcits_pid)        webcits_pid = start_webcits();
68
69                 sleep(1);                               // for sanity
70
71         } while(who_exited >= 0);
72         exit(0);
73 }