Index: trunk/user/ksh/ksh.c
===================================================================
--- trunk/user/ksh/ksh.c	(revision 418)
+++ trunk/user/ksh/ksh.c	(revision 427)
@@ -7,5 +7,4 @@
 ///////////////////////////////////////////////////////////////////////////////
 
-#include <nostdio.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -229,4 +228,28 @@
 }   // end cmd_cp()
 
+/////////////////////////////////////////
+static void cmd_fg(int argc, char **argv)
+{
+	unsigned int pid;
+
+	if (argc != 2) 
+    {
+		printf("  usage: %s pid\n", argv[0]);
+		return;
+	}
+
+    pid = atoi( argv[1] );   
+
+    if( pid == 0 )
+    {
+		printf("  error: ilegal pid format\n" );
+	}
+
+    if( fg( pid ) )
+    {
+		printf("  error: cannot find process %x\n", pid );
+	}
+}
+
 //////////////////////////////////////////////
 static void cmd_help( int argc , char **argv )
@@ -258,5 +281,10 @@
 	}
 
-	pid = atoi(argv[1]);
+	pid = atoi( argv[1] );
+
+    if( pid == 0 )
+    {
+		printf("  error: ilegal pid format\n" );
+	}
 
 	if( kill( pid , SIGKILL ) )
@@ -264,7 +292,4 @@
 		printf("  error: unable to kill process %x\n", pid );
 	}
-
-    printf("\n   ...  done\n" );
-
 }   // end cmd_kill()
 
@@ -272,11 +297,12 @@
 static void cmd_load( int argc , char **argv )
 {
-	unsigned int         pid;
-    unsigned int         error;
+	unsigned int         ret_pid;
+    unsigned int         new_pid;
 	char               * pathname;
-
-	if (argc != 2) 
-    {
-		printf("  usage: %s pathname \n", argv[0] );
+    unsigned int         background;
+
+	if( (argc < 2) || (argc > 3) )  
+    {
+		printf("  usage: %s pathname [&] \n", argv[0] );
 		return;
 	}
@@ -284,19 +310,25 @@
 	pathname = argv[1];
 
+    if( argc == 3 ) background = (argv[2][0] == '&');
+
     // fork system call
-	pid = fork();
-
-    if (pid == 0)  // it is the child process 
+	ret_pid = fork();
+
+    if (ret_pid == 0)  // it is the child process 
     {
         // exec system call
-        error = exec( pathname , NULL , NULL );
-
-        if( error )
+        if( exec( pathname , NULL , NULL ) )
         {
             printf("  error: new process unable to exec <%s>\n", pathname );
             exit(0);
         }
+
+        // get new process pid
+        new_pid = getpid();
+
+        // give new process terminal ownership
+        if( background == 0 ) fg( new_pid );
 	} 
-    else if ( pid < 0 )  // it is a failure reported to parent
+    else if ( ret_pid < 0 )  // it is a failure reported to parent
     {
         printf("  error: unable to fork\n");
@@ -443,22 +475,80 @@
 }
 
-///////////////////////////////////////////////
-static void cmd_sched( int argc , char **argv )
-{
-    unsigned int cxy;
-    unsigned int lid;
-
-	if (argc != 3)
-    {
-		printf("  usage: sched cxy lid\n");
-		return;
-	}
-
-	cxy = atoi(argv[1]);
-	lid = atoi(argv[2]);
-
-    if( get_sched( cxy , lid ) )
-    {
-        printf("  error: illegal arguments\n");
+/////////////////////////////////////////////////
+static void cmd_display( int argc , char **argv )
+{
+    unsigned int  cxy;
+    unsigned int  lid;
+    unsigned int  pid;
+
+    if( strcmp( argv[1] , "vmm" ) == 0 )
+    {
+        if( argc != 3 )
+        {
+		    printf("  usage: display vmm pid\n");
+		    return;
+	    }
+
+	    pid = atoi(argv[2]);
+
+        if( display_vmm( pid ) )
+        {
+            printf("  error: illegal arguments pid = %x\n", pid );
+        }
+    }
+    else if( strcmp( argv[1] , "sched" ) == 0 )
+    {
+        if( argc != 4 )
+        {
+		    printf("  usage: display sched cxy lid\n");
+		    return;
+	    }
+
+	    cxy = atoi(argv[2]);
+	    lid = atoi(argv[3]);
+
+        if( display_sched( cxy , lid ) )
+        {
+            printf("  error: illegal arguments cxy = %x / lid = %d\n", cxy, lid );
+        }
+    }
+    else if( strcmp( argv[1] , "process" ) == 0 )
+    {
+        if( argc != 3 )
+        {
+		    printf("  usage: display process cxy\n");
+		    return;
+	    }
+
+	    cxy = atoi(argv[2]);
+
+        if( display_process( cxy ) )
+        {
+            printf("  error: illegal argument cxy = %x\n", cxy );
+        }
+    }
+    else if( strcmp( argv[1] , "vfs" ) == 0 )
+    {
+        if( argc != 2 )
+        {
+		    printf("  usage: display vfs\n");
+		    return;
+	    }
+
+        display_vfs();
+    }
+    else if( strcmp( argv[1] , "chdev" ) == 0 )
+    {
+        if( argc != 2 )
+        {
+		    printf("  usage: display chdev\n");
+		    return;
+	    }
+
+        display_chdev();
+    }
+    else
+    {
+        printf("  usage display (vmm/sched/process/vfs/chdev) [cxy] [lid]\n");
     }
 }
@@ -470,19 +560,20 @@
 ksh_cmd_t cmd[] =
 {
-	{ "cat",    "display file content",                cmd_cat   },
-	{ "cd",     "change current directory",            cmd_cd    },
-	{ "cp",     "replicate a file in file system",     cmd_cp    },
-	{ "load",   "load an user application",            cmd_load  },
-	{ "help",   "list available commands",             cmd_help  },
-	{ "kill",   "kill an application (all threads)",   cmd_kill  },
-	{ "log",    "list registered commands",            cmd_log   },
-	{ "ls",     "list directory entries",              cmd_ls    },
-	{ "mkdir",  "create a new directory",              cmd_mkdir },
-	{ "mv",     "move a file in file system",          cmd_mv    },
-	{ "pwd",    "print current working directory",     cmd_pwd   },
-	{ "rm",     "remove a file from file system",      cmd_rm    },
-	{ "rmdir",  "remove a directory from file system", cmd_rmdir },
-    { "sched",  "display scheduler state",             cmd_sched },
-	{ NULL,     NULL,								   NULL      }
+	{ "cat",     "display file content",                cmd_cat     },
+	{ "cd",      "change current directory",            cmd_cd      },
+	{ "cp",      "replicate a file in file system",     cmd_cp      },
+    { "fg",      "put a process in foreground",         cmd_fg      },
+    { "display", "display vmm/sched/process/vfs/chdev", cmd_display },
+	{ "load",    "load an user application",            cmd_load    },
+	{ "help",    "list available commands",             cmd_help    },
+	{ "kill",    "kill an application (all threads)",   cmd_kill    },
+	{ "log",     "list registered commands",            cmd_log     },
+	{ "ls",      "list directory entries",              cmd_ls      },
+	{ "mkdir",   "create a new directory",              cmd_mkdir   },
+	{ "mv",      "move a file in file system",          cmd_mv      },
+	{ "pwd",     "print current working directory",     cmd_pwd     },
+	{ "rm",      "remove a file from file system",      cmd_rm      },
+	{ "rmdir",   "remove a directory from file system", cmd_rmdir   },
+	{ NULL,     NULL,								   NULL         }
 };
 
