Index: trunk/user/ksh/ksh.c
===================================================================
--- trunk/user/ksh/ksh.c	(revision 588)
+++ trunk/user/ksh/ksh.c	(revision 596)
@@ -21,5 +21,5 @@
 //   the TXT terminal ownership.
 //
-// A semaphore is used to synchronize the two KSH threads. At each iteration, 
+// We use a semaphore to synchronize the two KSH threads. At each iteration, 
 // the interactive thread check the semaphore (with a sem_wait). It blocks 
 // and deschedules, if the KSH process loosed the TXT ownership (after a load,
@@ -46,4 +46,7 @@
 #include <semaphore.h>
 #include <hal_macros.h>
+#include <sys/stat.h>
+#include <sys/mman.h>
+#include <fcntl.h>
 
 #define CMD_MAX_SIZE   (256)    // max number of characters in one command
@@ -53,4 +56,5 @@
 #define MAIN_DEBUG          0
 #define CMD_LOAD_DEBUG      0
+#define CMD_CAT_DEBUG       1
 
 //////////////////////////////////////////////////////////////////////////////////////////
@@ -99,53 +103,91 @@
 {
 	char         * path;
+    stat_t         st;      // stat structure
+    int            fd;
+    int            size;
+    char         * buf;
 
 	if (argc != 2) 
     {
+        fd   = -1;
+        buf  = NULL;
+        size = 0;
 		printf("  usage: cat pathname\n");
-		return;
-	}
-
-	path = argv[1];
-
-    printf("  error: not implemented yet\n", argc, argv );
-
-/*
-	// open the file
-	fd = open( path , O_RDONLY , 0 );
-	if (fd < 0) 
-    {
-		printf("  error: cannot open %s\n", path);
-		goto exit;
-	}
-
-	// get file size 
-	if (stat(path, &st) == -1)
-    {
-		printf("  error: cannot stat %s\n", path);
-		goto exit;
-	}
-	if (S_ISDIR(st.st_mode)) {
-		printf("  error: %s is a directory\n", path);
-		goto exit;
-	}
-	size = st.st_size;
-
-	// mmap the file 
-	buf = mmap(NULL, size, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0);
-	if (buf == NULL || buf == (char *)-1) {
-		printf("  error: cannot map %s\n", path);
-		goto exit;
-	}
-
-	// set terminating '0'
-	buf[size-1] = 0;
-
-	// display the file content
-	printf("%s", buf);
+        goto exit;
+    }
+
+    path = argv[1];
+
+    // open the file
+    fd = open( path , O_RDONLY , 0 );
+    if (fd < 0) 
+    {
+        buf  = NULL;
+        size = 0;
+	    printf("  error: cannot open %s\n", path);
+	    goto exit;
+    }
+
+#if CMD_CAT_DEBUG
+long long unsigned cycle;
+get_cycle( &cycle );
+printf("\n[%s] file %s open / cycle %d\n",
+__FUNCTION__ , path , (int)cycle );
+#endif
+
+    // get file stats 
+    if ( stat( path , &st ) == -1)
+    {
+        buf  = NULL;
+        size = 0;
+	    printf("  error: cannot stat %s\n", path);
+	    goto exit;
+    }
+
+   	if ( S_ISDIR(st.st_mode) )
+    {
+        buf  = NULL;
+        size = 0;
+   	    printf("  error: %s is a directory\n", path);
+	    goto exit;
+    }
+
+    // get file size
+    size = st.st_size;
+
+#if CMD_CAT_DEBUG
+get_cycle( &cycle );
+printf("\n[%s] get size %d / cycle %d\n",
+__FUNCTION__ , size , (int)cycle );
+#endif
+
+    // MAP_FILE is default type when MAP_ANON and MAP_REMOTE are not specified
+    buf = mmap( NULL , size , PROT_READ|PROT_WRITE , MAP_PRIVATE , fd , 0 );
+
+    if ( buf == NULL )
+    {
+  	    printf("  error: cannot map %s\n", path );
+	    goto exit;
+    }
+
+#if CMD_CAT_DEBUG
+get_cycle( &cycle );
+printf("\n[%s] map file %d to buffer %x / cycle %d\n",
+__FUNCTION__ , fd , buf , (int)cycle );
+display_vmm( 0 , getpid() );
+#endif
+
+    // display the file content on TXT terminal
+    write( 1 , buf , size );
+
+    // release semaphore to get next command
+    sem_post( &semaphore );
+
+    return;
 
 exit:
+
 	if (buf != NULL) munmap(buf, size);
 	if (fd >= 0) close(fd);
-*/
 
     // release semaphore to get next command
@@ -162,10 +204,11 @@
     {
 		printf("  usage: cd pathname\n");
-		return;
-	}
-
-	path = argv[1];
-
-    printf("  error: not implemented yet\n", argc, argv );
+	}
+    else
+    {
+	    path = argv[1];
+
+        printf("  error: not implemented yet\n" );
+    }
 
     // release semaphore to get next command
@@ -177,91 +220,115 @@
 static void cmd_cp(int argc, char **argv)
 {
-//	int src_fd = -1, dst_fd = -1;
-//	char *srcpath, *dstpath;
-//	struct stat st;
-//	size_t size, i;
-//	char buf[1024];
+  	int    src_fd;
+    int    dst_fd;
+  	char * srcpath;
+    char * dstpath;
+  	int    size;          // source file size
+  	int    bytes;         // number of transfered bytes
+  	char   buf[1024];
+  	stat_t st;
 
 	if (argc != 3) 
     {
+        src_fd = -1;
+        dst_fd = -1;
 		printf("  usage: cp src_pathname dst_pathname\n");
-		return;
-	}
-
-    printf("  error: not implemented yet\n", argc, argv );
-
-/*
-	srcpath = argv[1];
-	dstpath = argv[2];
-
-	// open the src file 
-	src_fd = open(srcpath, O_RDONLY, 0);
-	if (src_fd < 0) {
-		printf("  error: cannot open %s / err = %d\n", srcpath, errno);
-		goto exit;
-	}
-
-	// get file size 
-	if (stat(srcpath, &st) == -1) {
-		printf("  error: cannot stat %s\n", srcpath);
-		goto exit;
-	}
-	if (S_ISDIR(st.st_mode)) {
+        goto exit;
+	}
+
+    srcpath = argv[1];
+    dstpath = argv[2];
+
+    // open the src file 
+    src_fd = open( srcpath , O_RDONLY , 0 );
+
+    if ( src_fd < 0 ) 
+    {
+        dst_fd = -1;
+	    printf("  error: cannot open %s\n", srcpath );
+	    goto exit;
+    }
+
+    // get file stats
+    if ( stat( srcpath , &st ) )
+    {
+        dst_fd = -1;
+	    printf("  error: cannot stat %s\n", srcpath);
+	    goto exit;
+    }
+
+	if ( S_ISDIR(st.st_mode) )
+    {
+        dst_fd = -1;
 		printf("  error: %s is a directory\n", srcpath);
 		goto exit;
 	}
+
+    // get src file size
 	size = st.st_size;
 
 	// open the dst file 
-	dst_fd = open(dstpath, O_CREAT|O_TRUNC|O_RDWR, 0);
-	if (dst_fd < 0) {
-		printf("  error: cannot open %s / err = %d\n", dstpath, errno);
+	dst_fd = open( dstpath , O_CREAT|O_TRUNC|O_RDWR , 0 );
+
+	if ( dst_fd < 0 ) 
+    {
+		printf("  error: cannot open %s\n", dstpath );
 		goto exit;
 	}
-	if (stat(dstpath, &st) == -1) {
-		printf("  error: cannot stat %s\n", dstpath);
+
+	if ( stat( dstpath , &st ) )
+    {
+		printf("  error: cannot stat %s\n", dstpath );
 		goto exit;
 	}
-	if (S_ISDIR(st.st_mode)) {
-		printf("  error: %s is a directory\n", dstpath);
+
+	if ( S_ISDIR(st.st_mode ) ) 
+    {
+		printf("  error: %s is a directory\n", dstpath );
 		goto exit;
 	}
 
-	i = 0;
-	while (i < size)
+	bytes = 0;
+
+	while (bytes < size)
 	{
-		size_t rlen = (size - i < 1024 ? size - i : 1024);
-		size_t wlen;
-		ssize_t ret;
+		int rlen = ((size - bytes) < 1024) ? (size - bytes) : 1024;
+		int wlen;
+		int ret;
 
 		// read the source 
-		ret = read(src_fd, buf, rlen);
-		if (ret == -1) {
+		ret = read( src_fd , buf , rlen );
+		if (ret == -1) 
+        {
 			printf("  error: cannot read from file %s\n", srcpath);
 			goto exit;
 		}
-		rlen = (size_t)ret;
+
+		rlen = (int)ret;
 
 		// write to the destination 
-		ret = write(dst_fd, buf, rlen);
-		if (ret == -1) {
+		ret = write( dst_fd , buf , rlen );
+		if (ret == -1)
+        {
 			printf("  error: cannot write to file %s\n", dstpath);
 			goto exit;
 		}
-		wlen = (size_t)ret;
+
+		wlen = (int)ret;
 
 		// check 
-		if (wlen != rlen) {
+		if (wlen != rlen) 
+        {
 			printf("  error: cannot write on device\n");
 			goto exit;
 		}
 
-		i += rlen;
+		bytes += rlen;
 	}
 
 exit:
+
 	if (src_fd >= 0) close(src_fd);
 	if (dst_fd >= 0) close(dst_fd);
-*/
 
     // release semaphore to get next command
@@ -273,25 +340,34 @@
 static void cmd_display( int argc , char **argv )
 {
-    unsigned int  cxy;
-    unsigned int  lid;
-    unsigned int  pid;
-    unsigned int  txt_id;
-
-    if( strcmp( argv[1] , "vmm" ) == 0 )
+    if( argc < 2 )
+    {
+        printf("  usage: display  vmm      cxy  pid   \n"
+               "         display  sched    cxy  lid   \n"              
+               "         display  process  cxy        \n"              
+               "         display  txt      txtid      \n"              
+               "         display  vfs                 \n"              
+               "         display  chdev               \n"              
+               "         display  dqdt                \n"              
+               "         display  locks    pid  trdid \n");
+    }
+    ////////////////////////////////////
+    else if( strcmp( argv[1] , "vmm" ) == 0 )
     {
         if( argc != 4 )
         {
 		    printf("  usage: display vmm cxy pid\n");
-		    return;
-	    }
-
-	    cxy = atoi(argv[2]);
-	    pid = atoi(argv[3]);
-
-        if( display_vmm( cxy , pid ) )
-        {
-            printf("  error: no process %x in cluster %x\n", pid , cxy );
-        }
-    }
+	    }
+        else
+        {
+	        unsigned int cxy = atoi(argv[2]);
+	        unsigned int pid = atoi(argv[3]);
+
+            if( display_vmm( cxy , pid ) )
+            {
+                printf("  error: no process %x in cluster %x\n", pid , cxy );
+            }
+        }
+    }
+    ///////////////////////////////////////////
     else if( strcmp( argv[1] , "sched" ) == 0 )
     {
@@ -299,15 +375,17 @@
         {
 		    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
+        {
+	        unsigned int cxy = atoi(argv[2]);
+	        unsigned int 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 )
     {
@@ -315,14 +393,16 @@
         {
 		    printf("  usage: display process cxy\n");
-		    return;
-	    }
-
-	    cxy = atoi(argv[2]);
-
-        if( display_cluster_processes( cxy , 0 ) )
-        {
-            printf("  error: illegal argument cxy = %x\n", cxy );
-        }
-    }
+	    }
+        else
+        {
+	        unsigned int cxy = atoi(argv[2]);
+
+            if( display_cluster_processes( cxy , 0 ) )
+            {
+                printf("  error: illegal argument cxy = %x\n", cxy );
+            }
+        }
+    }
+    /////////////////////////////////////////
     else if( strcmp( argv[1] , "txt" ) == 0 )
     {
@@ -330,14 +410,16 @@
         {
 		    printf("  usage: display txt txt_id\n");
-		    return;
-	    }
-
-	    txt_id = atoi(argv[2]);
-
-        if( display_txt_processes( txt_id ) )
-        {
-            printf("  error: illegal argument txt_id = %d\n", txt_id );
-        }
-    }
+	    }
+        else
+        {
+	        unsigned int txtid = atoi(argv[2]);
+
+            if( display_txt_processes( txtid ) )
+            {
+                printf("  error: illegal argument txtid = %d\n", txtid );
+            }
+        }
+    }
+    /////////////////////////////////////////
     else if( strcmp( argv[1] , "vfs" ) == 0 )
     {
@@ -345,9 +427,11 @@
         {
 		    printf("  usage: display vfs\n");
-		    return;
-	    }
-
-        display_vfs();
-    }
+	    }
+        else
+        {
+            display_vfs();
+        }
+    }
+    //////////////////////////////////////////
     else if( strcmp( argv[1] , "chdev" ) == 0 )
     {
@@ -355,9 +439,11 @@
         {
 		    printf("  usage: display chdev\n");
-		    return;
-	    }
-
-        display_chdev();
-    }
+	    }
+        else
+        {
+            display_chdev();
+        }
+    }
+    //////////////////////////////////////////
     else if( strcmp( argv[1] , "dqdt" ) == 0 )
     {
@@ -365,13 +451,32 @@
         {
 		    printf("  usage: display dqdt\n");
-		    return;
-	    }
-
-        display_dqdt();
-    }
-    else
-    {
-        printf("  usage: display (vmm/sched/process/vfs/chdev/txt) [arg2] [arg3]\n");
-    }
+	    }
+        else
+        {
+            display_dqdt();
+        }
+    }
+    ///////////////////////////////////////////
+    else if( strcmp( argv[1] , "locks" ) == 0 )
+    {
+        if( argc != 4 )
+        {
+		    printf("  usage: display locks pid trdid\n");
+	    }
+        else
+        {
+	        unsigned int pid   = atoi(argv[2]);
+            unsigned int trdid = atoi(argv[3]);
+
+            if( display_busylocks( pid , trdid ) )
+            {
+                printf("  error: illegal arguments pid = %x / trdid = %x\n", pid, trdid );
+            }
+        }
+    }
+    else
+    {
+        printf("  error: undefined display request : %s\n", argv[1] ); 
+    }        
 
     // release semaphore to get next command
@@ -388,18 +493,18 @@
     {
 		printf("  usage: %s pid\n", argv[0]);
-		return;
-	}
-
-    pid = atoi( argv[1] );   
-
-    if( pid == 0 )
-    {
-		printf("  error: PID cannot be 0\n" );
-	}
-
-    if( fg( pid ) )
-    {
-		printf("  error: cannot find process %x\n", pid );
-	}
+	}
+    else
+    {
+        pid = atoi( argv[1] );   
+
+        if( pid == 0 )
+        {  
+		    printf("  error: PID cannot be 0\n" );
+	    }
+        else if( fg( pid ) )
+        {
+		    printf("  error: cannot find process %x\n", pid );
+	    }
+    }
 
     // release semaphore to get next command
@@ -416,12 +521,13 @@
     {
 		printf("  usage: %s\n", argv[0]);
-		return;
-	}
-
-	printf("available commands:\n");
-	for (i = 0 ; cmd[i].name ; i++) 
-    {
-		printf("\t%s\t : %s\n", cmd[i].name , cmd[i].desc);
-	}
+	}
+    else
+    {
+	    printf("available commands:\n");
+	    for (i = 0 ; cmd[i].name ; i++) 
+        {
+		    printf("\t%s\t : %s\n", cmd[i].name , cmd[i].desc);
+   	    }
+    }
 
     // release semaphore to get next command
@@ -438,18 +544,19 @@
     {
 		printf("  usage: %s pid\n", argv[0]);
-		return;
-	}
-
-	pid = atoi( argv[1] );
-
-    if( pid == 0 )
-    {
-		printf("  error: kernel process 0 cannot be killed\n" );
-	}
-
-	if( kill( pid , SIGKILL ) )
-    {
-		printf("  error: process %x cannot be killed\n", pid );
-	}
+	}
+    else
+    {
+	    pid = atoi( argv[1] );
+
+        if( pid == 0 )
+        {
+		    printf("  error: kernel process 0 cannot be killed\n" );
+	    }
+
+	    else if( kill( pid , SIGKILL ) )
+        {
+		    printf("  error: process %x cannot be killed\n", pid );
+	    }
+    }
 
     // release semaphore to get next command
@@ -472,39 +579,39 @@
     {
 		printf("  usage: %s pathname [cxy] [&]\n", argv[0] );
-		return;
-	}
-
-	pathname = argv[1];
-
-    if( argc == 2 )
-    {
-        background = 0;
-        placement  = 0;
-        cxy        = 0;
-    }
-    else if( argc == 3 )
-    {
-        if( (argv[2][0] == '&') && (argv[2][1] == 0) )
-        {
-            background = 1;
+	}
+    else
+    {
+	    pathname = argv[1];
+
+        if( argc == 2 )
+        {
+            background = 0;
             placement  = 0;
             cxy        = 0;
         }
-        else 
-        {
-            background = 0;
+        else if( argc == 3 )
+        {
+            if( (argv[2][0] == '&') && (argv[2][1] == 0) )
+            {
+                background = 1;
+                placement  = 0;
+                cxy        = 0;
+            }
+            else 
+            {
+                background = 0;
+                placement  = 1;
+                cxy        = atoi( argv[2] );
+            }
+        }
+        else  // argc == 4
+        { 
+            background = ( (argv[3][0] == '&') && (argv[3][1] == 0) );
             placement  = 1;
             cxy        = atoi( argv[2] );
         }
-    }
-    else  // argc == 4
-    { 
-        background = ( (argv[3][0] == '&') && (argv[3][1] == 0) );
-        placement  = 1;
-        cxy        = atoi( argv[2] );
-    }
-
-    // get KSH process PID
-    ksh_pid = getpid();
+
+        // get KSH process PID
+        ksh_pid = getpid();
 
 #if CMD_LOAD_DEBUG
@@ -515,17 +622,16 @@
 #endif
 
-    // set target cluster if required
-    if( placement ) place_fork( cxy );
-
-    // KSH process fork CHILD process
-	ret_fork = fork();
-
-    if ( ret_fork < 0 )     // it is a failure reported to KSH
-    {
-        printf("  error: ksh process unable to fork\n");
-        return;
-    }
-    else if (ret_fork == 0) // it is the CHILD process 
-    {
+        // set target cluster if required
+        if( placement ) place_fork( cxy );
+
+        // KSH process fork CHILD process
+	    ret_fork = fork();
+
+        if ( ret_fork < 0 )     // it is a failure reported to KSH
+        {
+            printf("  error: ksh process unable to fork\n");
+        }
+        else if (ret_fork == 0) // it is the CHILD process 
+        {
 
 #if CMD_LOAD_DEBUG
@@ -535,6 +641,6 @@
 #endif
 
-        // CHILD process exec NEW process
-        ret_exec = execve( pathname , NULL , NULL );
+            // CHILD process exec NEW process
+            ret_exec = execve( pathname , NULL , NULL );
 
 #if CMD_LOAD_DEBUG
@@ -544,13 +650,13 @@
 #endif
 
-        // this is only executed in case of exec failure
-        if( ret_exec )
-        {
-            printf("  error: child process unable to exec <%s>\n", pathname );
-            exit( 0 );
-        }   
-	} 
-    else                    // it is the KSH process : ret_fork is the new process PID
-    {
+            // this is only executed in case of exec failure
+            if( ret_exec )
+            {
+                printf("  error: child process unable to exec <%s>\n", pathname );
+                exit( 0 );
+            }   
+	    } 
+        else                    // it is the KSH process : ret_fork is the new process PID
+        {
 
 #if CMD_LOAD_DEBUG
@@ -560,13 +666,14 @@
 #endif
 
-        if( background )    // child in background =>  KSH must keep TXT ownership
-        {
-            // execve() tranfered TXT ownership to child => give it back to KSH
-            fg( ksh_pid );
-
-            // release semaphore to get next command
-            sem_post( &semaphore );
-        }
-    }
+            if( background )    // child in background =>  KSH must keep TXT ownership
+            {
+                fg( ksh_pid );
+            }
+        }
+    }
+
+    // release semaphore to get next command
+    sem_post( &semaphore );
+    
 }   // end cmd_load
 
@@ -579,12 +686,13 @@
     {
 		printf("  usage: %s\n", argv[0], argc ); 
-		return;
-	}
-
-	printf("--- registered commands ---\n");
-	for (i = 0; i < LOG_DEPTH; i++) 
-    {
-		printf(" - %d\t: %s\n", i, &log_entries[i].buf);
-	}
+	}
+    else
+    {
+	    printf("--- registered commands ---\n");
+	    for (i = 0; i < LOG_DEPTH; i++) 
+        {
+		    printf(" - %d\t: %s\n", i, &log_entries[i].buf);
+	    }
+    }
 
     // release semaphore to get next command
@@ -602,19 +710,14 @@
 //  DIR *dir;
 
-	if (argc == 1)
-    {
-		path = ".";
-	}
-    else if (argc == 2) 
-    {
-		path = argv[1];
-	} 
-    else 
+	if (argc > 2 )
     {
 		printf("  usage: ls [path]\n");
-		return;
-	}
-
-    printf("  error: not implemented yet\n");
+	}
+    else
+    {
+        if ( argc == 1 ) path = ".";
+        else             path = argv[1];
+
+        printf("  error: not implemented yet\n");
 /*
 	dir = opendir( path );
@@ -625,4 +728,5 @@
 	closedir(dir);
 */
+    }
 
     // release semaphore to get next command
@@ -639,10 +743,11 @@
     {
 		printf("  usage: mkdir pathname\n");
-		return;
-	}
-
-    pathname = argv[1];
-
-    printf("  error: not implemented yet\n");
+	}
+    else
+    {
+        pathname = argv[1];
+
+        printf("  error: not implemented yet\n");
+    }
 
     // release semaphore to get next command
@@ -657,9 +762,10 @@
 	if (argc < 3)
 	{
-		printf("  usage : %s src_pathname dst_pathname\n", argv[0]);
-		return;
-	}
-
-    printf("  error: not implemented yet\n");
+		printf("  usage : mv src_pathname dst_pathname\n");
+	}
+    else
+    {
+        printf("  error: not implemented yet\n");
+    }
     
     // release semaphore to get next command
@@ -681,16 +787,18 @@
     {
 		printf("  usage: %s\n", argv[0]);
-		return;
-	}
-
-    // get platform config
-    get_config( &x_size , &y_size , &ncores );
-
-    // scan all clusers
-    for( x = 0 ; x < x_size ; x++ )
-    {
-        for( y = 0 ; y < y_size ; y++ )
-        {
-            display_cluster_processes( HAL_CXY_FROM_XY(x,y), 1 );  // only owned processes
+	}
+    else
+    {
+        // get platform config
+        get_config( &x_size , &y_size , &ncores );
+
+        // scan all clusters
+        for( x = 0 ; x < x_size ; x++ )
+        {
+            for( y = 0 ; y < y_size ; y++ )
+            {
+                // display only owned processes
+                display_cluster_processes( HAL_CXY_FROM_XY(x,y), 1 ); 
+            }
         }
     }
@@ -709,15 +817,16 @@
     {
 		printf("  usage: %s\n", argv[0]);
-		return;
-	}
-
-	if ( getcwd( buf , 1024 ) ) 
-    {
-		printf("  error: unable to get current directory\n");
 	}
     else 
     {
-		printf("%s\n", buf);
-	}
+        if ( getcwd( buf , 1024 ) ) 
+        {
+		    printf("  error: unable to get current directory\n");
+	    }
+        else 
+        {
+		    printf("%s\n", buf);
+	    }
+    }
 
     // release semaphore to get next command
@@ -734,10 +843,11 @@
     {
 		printf("  usage: %s pathname\n", argv[0]);
-		return;
-	}
-
-	pathname = argv[1];
-
-    printf("  error: not implemented yet\n");
+	}
+    else
+    {
+	    pathname = argv[1];
+
+        printf("  error: not implemented yet\n");
+    }
 
     // release semaphore to get next command
@@ -762,13 +872,14 @@
     {
 		printf("  usage: trace cxy lid \n");
-		return;
-	}
-
-    cxy = atoi(argv[1]);
-    lid = atoi(argv[2]);
-
-    if( trace( 1 , cxy , lid ) )
-    {
-        printf("  error: core[%x,%d] not found\n", cxy, lid );
+	}
+    else
+    {
+        cxy = atoi(argv[1]);
+        lid = atoi(argv[2]);
+
+        if( trace( 1 , cxy , lid ) )
+        {
+            printf("  error: core[%x,%d] not found\n", cxy, lid );
+        }
     }
 
@@ -787,13 +898,14 @@
     {
 		printf("  usage: untrace cxy lid \n");
-		return;
-	}
-
-    cxy = atoi(argv[1]);
-    lid = atoi(argv[2]);
-
-    if( trace( 0 , cxy , lid ) )
-    {
-        printf("  error: core[%x,%d] not found\n", cxy, lid );
+	}
+    else
+    {
+        cxy = atoi(argv[1]);
+        lid = atoi(argv[2]);
+
+        if( trace( 0 , cxy , lid ) )
+        {
+            printf("  error: core[%x,%d] not found\n", cxy, lid );
+        }
     }
 
