Browse Source

Update pid in lockfile after daemonizing

git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/slim/trunk@109 7c53e7cc-98ea-0310-8f1f-a0b24da60408
sip 17 years ago
parent
commit
88b2dbb195
2 changed files with 12 additions and 0 deletions
  1. 11 0
      app.cpp
  2. 1 0
      app.h

+ 11 - 0
app.cpp

@@ -180,6 +180,7 @@ void App::Run() {
                 cerr << APPNAME << ": " << strerror(errno) << endl;
                 exit(ERR_EXIT);
             }
+            UpdatePid();
         }
 
         CreateServerAuth();
@@ -881,3 +882,13 @@ char* App::StrConcat(const char* str1, const char* str2) {
     strcat(tmp, str2);
     return tmp;
 }
+
+void App::UpdatePid() {
+    std::ofstream lockfile(cfg.getOption("lockfile").c_str(), ios_base::out);
+    if (!lockfile) {
+	    cerr << APPNAME << ": Could not update lock file: " << cfg.getOption("lockfile").c_str() << std::endl;
+	    exit(ERR_EXIT);
+    }
+    lockfile << getpid() << std::endl;
+    lockfile.close();
+}

+ 1 - 0
app.h

@@ -50,6 +50,7 @@ private:
     void HideCursor();
     void CreateServerAuth();
     char* StrConcat(const char* str1, const char* str2);
+    void UpdatePid();
  
     static std::string findValidRandomTheme(const std::string& set);
     static void replaceVariables(std::string& input,