#include <string.h>\r
#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
{"help", Command_Help}, {"clear", Command_Clear},\r
{"cd", Command_Cd}, {"dir", Command_Dir}\r
};\r
-static char *cDEFAULT_PATH[] = {"/Acess/Bin"};\r
+static char *cDEFAULT_PATH[] = {"/Acess/Bin","/Acess/SBin"};\r
#define BUILTIN_COUNT (sizeof(cBUILTINS)/sizeof(cBUILTINS[0]))\r
\r
// ==== LOCAL VARIABLES ====\r
- int giNumPathDirs = 1;\r
+ int giNumPathDirs = 2;\r
char **gasPathDirs = cDEFAULT_PATH;\r
char **gasEnvironment;\r
char gsCommandBuffer[1024];\r
\r
gasEnvironment = envp;\r
\r
- Command_Clear(0, NULL);\r
+// Command_Clear(0, NULL);\r
\r
{\r
char *tmp = getenv("CWD");\r
// Read Command line\r
sCommandStr = Readline( readline_state );\r
printf("\n");\r
+ if( !sCommandStr ) {\r
+ perror("Readline");\r
+ return 1;\r
+ }\r
\r
// Parse Command Line into arguments\r
iArgCount = Parse_Args(sCommandStr, saArgs);\r
\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