]> Dogcows Code - chaz/openbox/blobdiff - src/main.cc
move the restart into main.cc, so the openbox class can clean up properly before...
[chaz/openbox] / src / main.cc
index a422563d72d9e9cb504816598349be50ca9e5241..e59749aa6cfc22184a7e05f975f3b3626d53241b 100644 (file)
@@ -17,10 +17,16 @@ extern "C" {
 # include <stdio.h>
 #endif // HAVE_STDIO_H
 
+#ifdef    HAVE_UNISTD_H
+#  include <sys/types.h>
+#  include <unistd.h>
+#endif // HAVE_UNISTD_H
+
 #include "gettext.h"
 }
 
 #include "openbox.hh"
+#include "otk/util.hh"
 
 int main(int argc, char **argv) {
   // initialize the locale
@@ -32,4 +38,16 @@ int main(int argc, char **argv) {
 
   ob::Openbox openbox(argc, argv);
   openbox.eventLoop();
+
+  if (openbox.doRestart()) {
+    const std::string &prog = openbox.restartProgram();
+    if (!prog.empty()) {
+      execl("/bin/sh", "/bin/sh", "-c", prog.c_str(), NULL); 
+      perror(prog.c_str());
+    }
+    
+    // fall back in case the above execlp doesn't work
+    execvp(argv[0], argv);
+    execvp(otk::basename(argv[0]).c_str(), argv);
+  }
 }
This page took 0.020802 seconds and 4 git commands to generate.