From: John Hodge (sonata) Date: Sat, 10 Nov 2012 07:02:20 +0000 (+0800) Subject: Usermode/AxWin3 - Changed to use SysSpawn and detect crap server PIDs X-Git-Tag: rel0.15~664 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=fae63a3ca20775dbf083ba601bea317570e3dd64;p=tpg%2Facess2.git Usermode/AxWin3 - Changed to use SysSpawn and detect crap server PIDs --- diff --git a/Usermode/Applications/axwin3_src/WM/main.c b/Usermode/Applications/axwin3_src/WM/main.c index f1774a89..7d2d3914 100644 --- a/Usermode/Applications/axwin3_src/WM/main.c +++ b/Usermode/Applications/axwin3_src/WM/main.c @@ -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 diff --git a/Usermode/Applications/axwin3_src/libaxwin3.so_src/msg.c b/Usermode/Applications/axwin3_src/libaxwin3.so_src/msg.c index e9003e13..6c134a31 100644 --- a/Usermode/Applications/axwin3_src/libaxwin3.so_src/msg.c +++ b/Usermode/Applications/axwin3_src/libaxwin3.so_src/msg.c @@ -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 ++;