diff options
author | Mattias Andrée <maandree@operamail.com> | 2015-04-25 19:59:32 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2015-04-25 19:59:32 +0200 |
commit | 76fdcece687af8d82e7b5a6c065988ab80c914cb (patch) | |
tree | 361310df8206e56a60c3e9b891787d0d137ab18b /src/cmdline.c | |
parent | patch memory leak (diff) | |
download | bus-76fdcece687af8d82e7b5a6c065988ab80c914cb.tar.gz bus-76fdcece687af8d82e7b5a6c065988ab80c914cb.tar.bz2 bus-76fdcece687af8d82e7b5a6c065988ab80c914cb.tar.xz |
bus_read invokes callback with null message to notify that it is listening on the bus
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r-- | src/cmdline.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/cmdline.c b/src/cmdline.c index 40d0136..f9505cc 100644 --- a/src/cmdline.c +++ b/src/cmdline.c @@ -59,8 +59,10 @@ static const char *command; static int spawn_continue(const char *message, void *user_data) { - pid_t pid = fork(); - if (pid) + pid_t pid; + if (!message) + return 1; + if ((pid = fork())) return pid == -1 ? -1 : 1; setenv("arg", message, 1); execlp("sh", "sh", "-c", command, NULL); @@ -75,13 +77,15 @@ spawn_continue(const char *message, void *user_data) * * @param message The received message * @param user_data Not used - * @return 0 (stop listening) on success, -1 on error + * @return 0 (stop listening) on success, -1 on error, or 1 if `message` is `NULL` */ static int spawn_break(const char *message, void *user_data) { - pid_t pid = fork(); - if (pid) + pid_t pid; + if (!message) + return 1; + if (pid = fork()) return pid == -1 ? -1 : 0; setenv("arg", message, 1); execlp("sh", "sh", "-c", command, NULL); |