Usermode/libaxwin4 - Handle demarshal failure
[tpg/acess2.git] / Usermode / Applications / CLIShell_src / main.c
index 8cea364..6de92df 100644 (file)
@@ -9,6 +9,7 @@
 #include "header.h"\r
 #include <readline.h>\r
 #include <errno.h>\r
+#include <acess/devices/pty.h>\r
 \r
 #define _stdin 0\r
 #define _stdout        1\r
@@ -213,14 +214,28 @@ void CallCommand(char **Args)
        \r
        // Create new process\r
        int fds[] = {0, 1, 2};\r
+        int    status;\r
        pid = _SysSpawn(sTmpBuffer, (const char **)Args, (const char **)gasEnvironment, 3, fds, NULL);\r
        if(pid <= 0) {\r
                printf("Unable to create process: `%s'\n", sTmpBuffer); // Error Message\r
+               status = 0;\r
        }\r
        else {\r
-                int    status;\r
+               _SysIOCtl(0, PTY_IOCTL_SETPGRP, &pid);\r
                _SysWaitTID(pid, &status);\r
        }\r
+       \r
+       // Return terminal to a sane state\r
+       {\r
+               int zero = 0;\r
+               _SysIOCtl(0, PTY_IOCTL_SETPGRP, &zero);\r
+               printf("\x1b[0m");\r
+       }\r
+       // Print a status message if termination was non-clean\r
+       if( status )\r
+       {\r
+               printf("[%i] exited %i\n", pid, status);\r
+       }\r
 }\r
 \r
 /**\r

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