Usermode/AxWin3 - Changed to use SysSpawn and detect crap server PIDs
authorJohn Hodge (sonata) <[email protected]>
Sat, 10 Nov 2012 07:02:20 +0000 (15:02 +0800)
committerJohn Hodge (sonata) <[email protected]>
Sat, 10 Nov 2012 07:02:20 +0000 (15:02 +0800)
Usermode/Applications/axwin3_src/WM/main.c
Usermode/Applications/axwin3_src/libaxwin3.so_src/msg.c

index f1774a8..7d2d391 100644 (file)
@@ -46,8 +46,6 @@ const char    *gsInstallRoot = __INSTALL_ROOT;
  */
 int main(int argc, char *argv[])
 {
-        int    server_tid = gettid();
-       
        ParseCommandline(argc, argv);
        
        if( gsTerminalDevice == NULL ) {
@@ -74,16 +72,20 @@ int main(int argc, char *argv[])
        WM_Hotkey_Register(2, keys, "Interface>Run");
        
        // Spawn interface root
-       if( clone(CLONE_VM, 0) == 0 )
        {
+               int     server_tid = gettid();
+               _SysDebug("server_tid = %i", server_tid);
                static char csInterfaceApp[] = __INSTALL_ROOT"/AxWinUI";
                char    server_info[] = "AXWIN3_SERVER=00000";
-               char    *envp[] = {server_info, NULL};
-               char    *argv[] = {csInterfaceApp, NULL};
+               const char      *envp[] = {server_info, NULL};
+               const char      *argv[] = {csInterfaceApp, NULL};
                _SysDebug("server_tid = %i, &server_tid = %p", server_tid, &server_tid);
                sprintf(server_info, "AXWIN3_SERVER=%i", server_tid);
-               execve(csInterfaceApp, argv, envp);
-               exit(1);
+               // TODO: Does the client need FDs?
+                int    rv = _SysSpawn(csInterfaceApp, argv, envp, 0, NULL, NULL);
+               if( rv ) {
+                       _SysDebug("_SysSpawn chucked a sad, rv=%i, errno=%i", rv, _errno);
+               }
        }
 
        // Main Loop
index e9003e1..6c134a3 100644 (file)
@@ -33,9 +33,8 @@ tAxWin3_MessageCallback       gAxWin3_MessageCallback;
 // === CODE ===
 void AxWin3_Connect(const char *ServerDesc)
 {
-       _SysDebug("ServerDesc = %s", ServerDesc);
-       if( !ServerDesc )
-       {
+       _SysDebug("ServerDesc (argument) = %s", ServerDesc);
+       if( !ServerDesc ) {
                ServerDesc = gsAxWin3_int_ServerDesc;
        }
        _SysDebug("ServerDesc = %s", ServerDesc);
@@ -50,6 +49,10 @@ void AxWin3_Connect(const char *ServerDesc)
        case '6': case '7': case '8': case '9': case '0':
                giConnectionType = CONNTYPE_SENDMESSAGE;
                giConnectionNum = atoi(ServerDesc);
+               if( giConnectionNum == 0 ) {
+                       _SysDebug("Invalid server PID");
+                       exit(-1);
+               }
                break;
        case 'u':
                while(*ServerDesc && *ServerDesc != ':')        ServerDesc ++;

UCC git Repository :: git.ucc.asn.au