From dbc4b84e22a89157642aa784df731557f29bad3e Mon Sep 17 00:00:00 2001 From: Alexey Shilov Date: Fri, 20 Aug 2010 16:00:43 +0300 Subject: [PATCH] Changes: pass pid of invoker from booster to launcher --- src/launcher/daemon.cpp | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/launcher/daemon.cpp b/src/launcher/daemon.cpp index e52be98..b85007b 100644 --- a/src/launcher/daemon.cpp +++ b/src/launcher/daemon.cpp @@ -147,6 +147,20 @@ void Daemon::run() ssize_t count = read(m_pipefd[0], reinterpret_cast(&msg), 1); if (count) { + + // read pid of peer invoker + pid_t invoker_pid; + count = read(m_pipefd[0], reinterpret_cast(&invoker_pid), sizeof(pid_t)); + + if (count < sizeof(pid_t)) + { + Logger::logErrorAndDie(EXIT_FAILURE, "Daemon: pipe connection with booster failed"); + } + else + { + Logger::logError("Daemon: invokers pid: \n", invoker_pid); + } + // Fork a new booster of the given type // 2nd param guarantees some time for the just launched application @@ -233,9 +247,6 @@ bool Daemon::forkBooster(char type, int sleepTime) // Give to the process an application specific name booster->renameProcess(m_initialArgc, m_initialArgv); - pid_t pid = booster->invokersPid(); - //Logger::logError("Daemon: invokers pid: %d \n", pid); - // Signal the parent process that it can create a new // waiting booster process and close write end const char msg = booster->boosterType(); @@ -244,6 +255,13 @@ bool Daemon::forkBooster(char type, int sleepTime) Logger::logError("Daemon: Can't send signal to launcher process' \n"); } + // Send to the parent process pid of invoker for tracking + pid_t pid = booster->invokersPid(); + ret = write(m_pipefd[1], reinterpret_cast(&pid), sizeof(pid_t)); + if (ret == -1) { + Logger::logError("Daemon: Can't send invoker's pid to launcher process' \n"); + } + // close pipe close(m_pipefd[1]);