From 1fcca22670156fe054464e52b8bbe813776387bc Mon Sep 17 00:00:00 2001 From: Jussi Lind Date: Thu, 30 Sep 2010 16:56:51 +0300 Subject: [PATCH] Changes: Communication stuff moved from Booster::initialize() to a separate method sendDataToParent(). --- src/launcher/booster.cpp | 25 ++++++++++++++++--------- src/launcher/booster.h | 4 ++++ 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/launcher/booster.cpp b/src/launcher/booster.cpp index e2b3c1c..f4d45ea 100644 --- a/src/launcher/booster.cpp +++ b/src/launcher/booster.cpp @@ -83,6 +83,22 @@ void Booster::initialize(int initialArgc, char ** initialArgv, int newPipeFd[2]) // has been read from invoker in readCommand(). renameProcess(initialArgc, initialArgv); + // Send parent process a message that it can create a new booster, + // send pid of invoker, send booster respawn value + sendDataToParent(); + + // close pipe + close(pipeFd(1)); + + // Don't care about fate of parent applauncherd process any more + prctl(PR_SET_PDEATHSIG, 0); + + // Set dumpable flag + prctl(PR_SET_DUMPABLE, 1); +} + +void Booster::sendDataToParent() +{ // Signal the parent process that it can create a new // waiting booster process and close write end const char msg = boosterType(); @@ -101,15 +117,6 @@ void Booster::initialize(int initialArgc, char ** initialArgv, int newPipeFd[2]) if (write(pipeFd(1), reinterpret_cast(&delay), sizeof(int)) == -1) { Logger::logError("Booster: Couldn't send respawn delay value to launcher process\n"); } - - // close pipe - close(pipeFd(1)); - - // Don't care about fate of parent applauncherd process any more - prctl(PR_SET_PDEATHSIG, 0); - - // Set dumpable flag - prctl(PR_SET_DUMPABLE, 1); } bool Booster::readCommand() diff --git a/src/launcher/booster.h b/src/launcher/booster.h index 9f5a916..2657102 100644 --- a/src/launcher/booster.h +++ b/src/launcher/booster.h @@ -142,6 +142,10 @@ private: //! Disable assignment operator Booster & operator= (const Booster & r); + //! Send data to the parent process (invokers pid, respwan delay) + //! and signal that a new booster can be created. + void sendDataToParent(); + //! Load the library and jump to main int launchProcess();