aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/examples/daemon-depedencies/await-ready.c7
-rw-r--r--doc/examples/daemon-depedencies/await-started.c9
2 files changed, 9 insertions, 7 deletions
diff --git a/doc/examples/daemon-depedencies/await-ready.c b/doc/examples/daemon-depedencies/await-ready.c
index 03df950..5dfd9a7 100644
--- a/doc/examples/daemon-depedencies/await-ready.c
+++ b/doc/examples/daemon-depedencies/await-ready.c
@@ -48,7 +48,8 @@ static int callback(const char *message, void *user_data)
ppid = getppid();
pid = fork();
if (pid == 0) {
- announce_wait(ppid);
+ if (fork() == 0)
+ announce_wait(ppid);
exit(0);
} else {
(void) waitpid(pid, NULL, 0); /* Let's pretend everything will go swimmingly. */
@@ -59,7 +60,7 @@ static int callback(const char *message, void *user_data)
strncpy(msg, message, BUS_MEMORY_SIZE - 1);
msg[BUS_MEMORY_SIZE - 1] = 0;
- arg2 = strchr(message, ' ');
+ arg2 = strchr(msg, ' ');
if (!arg2)
return 1;
arg3 = strchr(++arg2, ' ');
@@ -90,7 +91,7 @@ int main(int argc_, char *argv_[])
if (argc < 2)
return fprintf(stderr, "USAGE: %s daemon...", *argv), 2;
t(bus_open(&bus, getenv("BUS_INIT"), BUS_RDONLY));
- started = calloc(argc - 1, sizeof(char));
+ started = calloc(argc, sizeof(char));
t(started == NULL);
started[0] = 1;
diff --git a/doc/examples/daemon-depedencies/await-started.c b/doc/examples/daemon-depedencies/await-started.c
index 152f02c..1b75fc6 100644
--- a/doc/examples/daemon-depedencies/await-started.c
+++ b/doc/examples/daemon-depedencies/await-started.c
@@ -48,7 +48,8 @@ static int callback(const char *message, void *user_data)
ppid = getppid();
pid = fork();
if (pid == 0) {
- announce_wait(ppid);
+ if (fork() == 0)
+ announce_wait(ppid);
exit(0);
} else {
(void) waitpid(pid, NULL, 0); /* Let's pretend everything will go swimmingly. */
@@ -59,7 +60,7 @@ static int callback(const char *message, void *user_data)
strncpy(msg, message, BUS_MEMORY_SIZE - 1);
msg[BUS_MEMORY_SIZE - 1] = 0;
- arg2 = strchr(message, ' ');
+ arg2 = strchr(msg, ' ');
if (!arg2)
return 1;
arg3 = strchr(++arg2, ' ');
@@ -89,8 +90,8 @@ int main(int argc_, char *argv_[])
if (argc < 2)
return fprintf(stderr, "USAGE: %s daemon...", *argv), 2;
- t(bus_open(&bus, getenv("BUS_INIT"), BUS_WRONLY));
- started = calloc(argc - 1, sizeof(char));
+ t(bus_open(&bus, getenv("BUS_INIT"), BUS_RDONLY));
+ started = calloc(argc, sizeof(char));
t(started == NULL);
started[0] = 1;