[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    kdelibs/kinit
From:       Waldo Bastian <bastian () kde ! org>
Date:       2002-12-15 20:53:21
[Download RAW message or body]

CVS commit by waba: 

CCMAIL: coolo@kde.org
Give KLauncher a normal main() just like all other programs.


  M +38 -50    kinit.cpp   1.108
  M +1 -0      klauncher_main.cpp   1.29


--- kdelibs/kinit/kinit.cpp  #1.107:1.108
@@ -350,7 +350,5 @@ static pid_t launch(int argc, const char
   if (strcmp(_name, "klauncher") == 0) {
      /* klauncher is launched in a special way:
-      * instead of calling 'main(argc, argv)',
-      * we call 'start_launcher(comm_socket)'.
-      * The other end of the socket is d.launcher[0].
+      * It has a communication socket on fd 3
       */
      if (0 > socketpair(AF_UNIX, SOCK_STREAM, 0, d.launcher))
@@ -413,4 +411,17 @@ static pid_t launch(int argc, const char
      close(d.fd[0]);
      close_fds();
+     if (launcher)
+     {
+        if (d.fd[1] == 3)
+        {
+          d.fd[1] = dup(d.fd[1]); // Evacuate from fd 3
+        }
+        if (d.launcher[1] != 3)
+        {
+          dup2( d.launcher[1], 3); // Make sure the socket has fd 3
+          close( d.launcher[1] );
+        }
+        
+     }
 
      if (cwd && *cwd)
@@ -516,6 +527,4 @@ static pid_t launch(int argc, const char
      }
 
-     if (!launcher)
-     {
         d.sym = lt_dlsym( d.handle, "kdemain");
         if (!d.sym )
@@ -546,30 +555,9 @@ static pid_t launch(int argc, const char
         }
         else
-            setup_tty( tty );
-
-        exit( d.func(argc, d.argv)); /* Launch! */
-     }
-     else
-     {
-        d.sym = lt_dlsym( d.handle, "start_launcher");
-        if (!d.sym )
         {
-           const char * ltdlError = lt_dlerror();
-           fprintf(stderr, "Could not find start_launcher: %s\n", ltdlError != 0 ? \
                ltdlError : "(null)" );
-           d.result = 1; // Error
-           write(d.fd[1], &d.result, 1);
-           close(d.fd[1]);
-           exit(255);
+        setup_tty( tty );
         }
 
-        d.result = 0; // Success
-        write(d.fd[1], &d.result, 1);
-        close(d.fd[1]);
-
-        d.launcher_func = (int (*)(int)) d.sym;
-        close(d.launcher[0]); // Close non-used socket.
-
-        exit( d.launcher_func( d.launcher[1] )); /* Launch! */
-     }
+     exit( d.func(argc, d.argv)); /* Launch! */
 
      break;

--- kdelibs/kinit/klauncher_main.cpp  #1.28:1.29
@@ -89,4 +89,5 @@ start_launcher(int socket)
 int main(/*int argc, char **argv*/)
 {
+   start_launcher(3);
    return 0;
 }


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic