Index: trunk/kernel/kern/process.c
===================================================================
--- trunk/kernel/kern/process.c	(revision 433)
+++ trunk/kernel/kern/process.c	(revision 435)
@@ -51,5 +51,5 @@
 #include <elf.h>
 #include <syscalls.h>
-#include <signal.h>
+#include <shared_syscalls.h>
 
 //////////////////////////////////////////////////////////////////////////////////////////
@@ -114,9 +114,9 @@
     // get model process cluster and local pointer
     model_cxy = GET_CXY( model_xp );
-    model_ptr = (process_t *)GET_PTR( model_xp );
+    model_ptr = GET_PTR( model_xp );
 
     // get parent process cluster and local pointer
     parent_cxy = GET_CXY( parent_xp );
-    parent_ptr = (process_t *)GET_PTR( parent_xp );
+    parent_ptr = GET_PTR( parent_xp );
 
     // get model_pid and parent_pid
@@ -209,5 +209,5 @@
         // get cluster and local pointer on chdev
         chdev_cxy = GET_CXY( chdev_xp );
-        chdev_ptr = (chdev_t *)GET_PTR( chdev_xp );
+        chdev_ptr = GET_PTR( chdev_xp );
  
         // get TXT terminal index
@@ -289,5 +289,5 @@
     // get reference process cluster and local pointer
     cxy_t       ref_cxy = GET_CXY( reference_process_xp );
-    process_t * ref_ptr = (process_t *)GET_PTR( reference_process_xp );
+    process_t * ref_ptr = GET_PTR( reference_process_xp );
 
     // initialize PID, REF_XP, PARENT_XP, and STATE
@@ -364,5 +364,4 @@
     process_t * parent_ptr;
     cxy_t       parent_cxy;
-    xptr_t      parent_thread_xp;
     xptr_t      children_lock_xp;
     xptr_t      copies_lock_xp;
@@ -450,6 +449,6 @@
 }
 
-////////////////////////////////////////////
-void process_sigaction( process_t * process,
+////////////////////////////////////////
+void process_sigaction( pid_t       pid,
                         uint32_t    action_type )
 {
@@ -467,13 +466,12 @@
     rpc_desc_t         rpc;               // rpc descriptor allocated in stack
 
+    thread_t * client = CURRENT_THREAD;
+
 #if CONFIG_DEBUG_PROCESS_SIGACTION
 uint32_t cycle = (uint32_t)hal_get_cycles();
 if( CONFIG_DEBUG_PROCESS_SIGACTION < cycle )
-printk("\n[DBG] %s : thread %x enter to %s process %x in cluster %x / cycle %d\n",
-__FUNCTION__ , CURRENT_THREAD, process_action_str( action_type ) ,
-process->pid , local_cxy , cycle );
-#endif
-
-    thread_t         * client = CURRENT_THREAD;
+printk("\n[DBG] %s : thread %x enter to %s process %x / cycle %d\n",
+__FUNCTION__ , client, process_action_str( action_type ) , pid , cycle );
+#endif
 
     // get local pointer on local cluster manager
@@ -481,12 +479,12 @@
 
     // get owner cluster identifier and process lpid
-    owner_cxy = CXY_FROM_PID( process->pid );
-    lpid      = LPID_FROM_PID( process->pid );
-
-    // check owner cluster
-    assert( (owner_cxy == local_cxy) , __FUNCTION__ , "must be executed in owner cluster\n" ); 
-   
-    // get number of remote copies
-    responses = cluster->pmgr.copies_nr[lpid] - 1;
+    owner_cxy = CXY_FROM_PID( pid );
+    lpid      = LPID_FROM_PID( pid );
+
+    // get root of list of copies, lock, and number of copies from owner cluster
+    responses = hal_remote_lw ( XPTR( owner_cxy , &cluster->pmgr.copies_nr[lpid] ) );
+    root_xp   = hal_remote_lwd( XPTR( owner_cxy , &cluster->pmgr.copies_root[lpid] ) );
+    lock_xp   = hal_remote_lwd( XPTR( owner_cxy , &cluster->pmgr.copies_lock[lpid] ) );
+
     rsp_count = 0;
 
@@ -502,8 +500,4 @@
     rpc.thread   = client;
 
-    // get extended pointers on copies root and lock
-    root_xp   = XPTR( local_cxy , &cluster->pmgr.copies_root[lpid] );
-    lock_xp   = XPTR( local_cxy , &cluster->pmgr.copies_lock[lpid] );
-
     // take the lock protecting the copies
     remote_spinlock_lock( lock_xp );
@@ -514,20 +508,19 @@
         process_xp  = XLIST_ELEMENT( iter_xp , process_t , copies_list );
         process_cxy = GET_CXY( process_xp );
-        process_ptr = (process_t *)GET_PTR( process_xp );
-
-        // send RPC to remote clusters
-        if( process_cxy != local_cxy )  
-        {
+        process_ptr = GET_PTR( process_xp );
 
 #if CONFIG_DEBUG_PROCESS_SIGACTION 
 if( CONFIG_DEBUG_PROCESS_SIGACTION < cycle )
-printk("\n[DBG] %s : send RPC to remote cluster %x\n", __FUNCTION__ , process_cxy );
-#endif
-
-            rpc.args[0] = (uint64_t)action_type;
-            rpc.args[1] = (uint64_t)(intptr_t)process_ptr;
-            rpc_process_sigaction_client( process_cxy , &rpc );
-            rsp_count++;
-        }
+printk("\n[DBG] %s : send RPC to cluster %x\n", __FUNCTION__ , process_cxy );
+#endif
+
+        // check PID
+        assert( (hal_remote_lw( XPTR( process_cxy , &process_ptr->pid) ) == pid),
+        __FUNCTION__ , "unconsistent PID value\n" );
+
+        rpc.args[0] = (uint64_t)action_type;
+        rpc.args[1] = (uint64_t)pid;
+        rpc_process_sigaction_client( process_cxy , &rpc );
+        rsp_count++;
     }
    
@@ -540,20 +533,7 @@
     rsp_count , responses );
 
-    // block and deschedule to wait RPC responses if required
-    if( responses )
-    {   
-        thread_block( CURRENT_THREAD , THREAD_BLOCKED_RPC );
-        sched_yield("BLOCKED on RPC_PROCESS_SIGACTION");
-    }
-
-#if CONFIG_DEBUG_PROCESS_SIGACTION
-if( CONFIG_DEBUG_PROCESS_SIGACTION < cycle )
-printk("\n[DBG] %s : make action in owner cluster %x\n", __FUNCTION__ , local_cxy );
-#endif
-
-    // call directly the relevant function in local owner cluster
-    if      (action_type == DELETE_ALL_THREADS  ) process_delete_threads ( process ); 
-    else if (action_type == BLOCK_ALL_THREADS   ) process_block_threads  ( process ); 
-    else if (action_type == UNBLOCK_ALL_THREADS ) process_unblock_threads( process );
+    // block and deschedule to wait RPC responses 
+    thread_block( CURRENT_THREAD , THREAD_BLOCKED_RPC );
+    sched_yield("BLOCKED on RPC_PROCESS_SIGACTION");
 
 #if CONFIG_DEBUG_PROCESS_SIGACTION
@@ -561,5 +541,5 @@
 if( CONFIG_DEBUG_PROCESS_SIGACTION < cycle )
 printk("\n[DBG] %s : thread %x exit after %s process %x in cluster %x / cycle %d\n",
-__FUNCTION__ , CURRENT_THREAD, process_action_str( action_type ) ,
+__FUNCTION__ , client, process_action_str( action_type ) ,
 process->pid , local_cxy , cycle );
 #endif
@@ -778,5 +758,5 @@
     {
         process_xp  = XLIST_ELEMENT( iter , process_t , local_list );
-        process_ptr = (process_t *)GET_PTR( process_xp );
+        process_ptr = GET_PTR( process_xp );
         if( process_ptr->pid == pid )
         {
@@ -838,5 +818,5 @@
 
     // get reference process cluster and local pointer
-    process_t * ref_ptr = (process_t *)GET_PTR( ref_xp );
+    process_t * ref_ptr = GET_PTR( ref_xp );
     cxy_t       ref_cxy = GET_CXY( ref_xp );
 
@@ -858,5 +838,5 @@
     // get reference process cluster and local pointer
     xptr_t ref_xp = process->ref_xp;
-    process_t * ref_ptr = (process_t *)GET_PTR( ref_xp );
+    process_t * ref_ptr = GET_PTR( ref_xp );
     cxy_t       ref_cxy = GET_CXY( ref_xp );
 
@@ -900,5 +880,5 @@
         xptr_t      ref_xp  = process->ref_xp;
         cxy_t       ref_cxy = GET_CXY( ref_xp );
-        process_t * ref_ptr = (process_t *)GET_PTR( ref_xp );
+        process_t * ref_ptr = GET_PTR( ref_xp );
 
         // access reference process descriptor
@@ -925,9 +905,9 @@
     // get cluster and local pointer for src fd_array
     cxy_t        src_cxy = GET_CXY( src_xp );
-    fd_array_t * src_ptr = (fd_array_t *)GET_PTR( src_xp );
+    fd_array_t * src_ptr = GET_PTR( src_xp );
 
     // get cluster and local pointer for dst fd_array
     cxy_t        dst_cxy = GET_CXY( dst_xp );
-    fd_array_t * dst_ptr = (fd_array_t *)GET_PTR( dst_xp );
+    fd_array_t * dst_ptr = GET_PTR( dst_xp );
 
     // get the remote lock protecting the src fd_array
@@ -1044,5 +1024,5 @@
     // get cluster and local pointer for parent process
     cxy_t       parent_process_cxy = GET_CXY( parent_process_xp );
-    process_t * parent_process_ptr = (process_t *)GET_PTR( parent_process_xp );
+    process_t * parent_process_ptr = GET_PTR( parent_process_xp );
 
     // get parent process PID and extended pointer on .elf file
@@ -1349,63 +1329,4 @@
 }  // end process_make_exec()
 
-////////////////////////////////////////////
-void process_make_kill( process_t * process,
-                        bool_t      is_exit,
-                        uint32_t    exit_status )
-{
-    thread_t * this = CURRENT_THREAD;
-
-    assert( (CXY_FROM_PID( process->pid ) == local_cxy) , __FUNCTION__ ,
-    "must be executed in process owner cluster\n" );
-
-    assert( ( this->type == THREAD_RPC ) , __FUNCTION__ ,
-    "must be executed by an RPC thread\n" );
-
-#if CONFIG_DEBUG_PROCESS_MAKE_KILL
-uint32_t cycle = (uint32_t)hal_get_cycles();
-if( CONFIG_DEBUG_PROCESS_MAKE_KILL < cycle )
-printk("\n[DBG] %s : thread %x enter for process %x / cycle %d\n",
-__FUNCTION__, this , process->pid , cycle );
-#endif
-
-    // register exit_status in owner process descriptor
-    if( is_exit ) process->term_state = exit_status;
-
-    // atomically update owner process descriptor flags
-    if( is_exit ) hal_atomic_or( &process->term_state , PROCESS_FLAG_EXIT );
-    else          hal_atomic_or( &process->term_state , PROCESS_FLAG_KILL );
-
-    // remove TXT ownership from owner process descriptor
-    process_txt_reset_ownership( XPTR( local_cxy , process ) );
-
-    // block all process threads in all clusters
-    process_sigaction( process , BLOCK_ALL_THREADS );
-
-    // mark all process threads in all clusters for delete 
-    process_sigaction( process , DELETE_ALL_THREADS );
-
-/* unused if sys_wait deschedules without blocking [AG]
-
-    // get cluster and pointers on reference parent process
-    xptr_t      parent_xp  = process->parent_xp;
-    process_t * parent_ptr = GET_PTR( parent_xp );
-    cxy_t       parent_cxy = GET_CXY( parent_xp );
-
-    // get loal pointer on parent main thread
-    thread_t * main_ptr = hal_remote_lpt( XPTR( parent_cxy , &parent_ptr->th_tbl[0] ) );
- 
-    // reset THREAD_BLOCKED_WAIT bit in parent process main thread
-    thread_unblock( XPTR( parent_cxy , main_ptr ) , THREAD_BLOCKED_WAIT );
-*/
-
-#if CONFIG_DEBUG_PROCESS_MAKE_KILL
-cycle = (uint32_t)hal_get_cycles();
-if( CONFIG_DEBUG_PROCESS_MAKE_KILL < cycle )
-printk("\n[DBG] %s : thread %x exit for process %x / cycle %d\n",
-__FUNCTION__, this, process->pid , cycle );
-#endif
-
-}  // end process_make_kill()
-
 ///////////////////////////////////////////////
 void process_zero_create( process_t * process )
@@ -1679,5 +1600,5 @@
 if( CONFIG_DEBUG_PROCESS_TXT_ATTACH < cycle )
 printk("\n[DBG] %s : thread %x enter for process %x / txt_id = %d  / cycle %d\n",
-__FUNCTION__, CURRENT_THREAD, process->pid, txt_id, cycle );
+__FUNCTION__, CURRENT_THREAD, process, txt_id, cycle );
 #endif
 
@@ -1708,5 +1629,5 @@
 if( CONFIG_DEBUG_PROCESS_TXT_ATTACH < cycle )
 printk("\n[DBG] %s : thread %x exit for process %x / txt_id = %d / cycle %d\n",
-__FUNCTION__, CURRENT_THREAD, process->pid, txt_id , cycle );
+__FUNCTION__, CURRENT_THREAD, process, txt_id , cycle );
 #endif
 
@@ -1721,9 +1642,9 @@
     xptr_t      lock_xp;      // extended pointer on list lock in chdev
 
-#if CONFIG_DEBUG_PROCESS_TXT_DETACH
+#if CONFIG_DEBUG_PROCESS_TXT_ATTACH
 uint32_t cycle = (uint32_t)hal_get_cycles();
-if( CONFIG_DEBUG_PROCESS_TXT_DETACH < cycle )
+if( CONFIG_DEBUG_PROCESS_TXT_ATTACH < cycle )
 printk("\n[DBG] %s : thread %x enter for process %x / cycle %d\n",
-__FUNCTION__, CURRENT_THREAD, process->pid , cycle );
+__FUNCTION__, CURRENT_THREAD, process, cycle );
 #endif
 
@@ -1745,9 +1666,9 @@
     remote_spinlock_unlock( lock_xp );
    
-#if CONFIG_DEBUG_PROCESS_TXT_DETACH
-cycle = (uint32_t)hal_get_cycles();
-if( CONFIG_DEBUG_PROCESS_TXT_DETACH < cycle )
+#if CONFIG_DEBUG_PROCESS_TXT_ATTACH
+cycle = (uint32_t)hal_get_cycles();
+if( CONFIG_DEBUG_PROCESS_TXT_ATTACH < cycle )
 printk("\n[DBG] %s : thread %x exit for process %x / cycle %d\n",
-__FUNCTION__, CURRENT_THREAD, process->pid, cycle );
+__FUNCTION__, CURRENT_THREAD, process, cycle );
 #endif
 
@@ -1766,5 +1687,5 @@
     // get cluster and local pointer on process
     process_cxy = GET_CXY( process_xp );
-    process_ptr = (process_t *)GET_PTR( process_xp );
+    process_ptr = GET_PTR( process_xp );
 
     // get extended pointer on stdin pseudo file
@@ -1774,5 +1695,5 @@
     txt_xp  = chdev_from_file( file_xp );
     txt_cxy = GET_CXY( txt_xp );
-    txt_ptr = (chdev_t *)GET_PTR( txt_xp );
+    txt_ptr = GET_PTR( txt_xp );
 
     // set owner field in TXT chdev
@@ -1804,5 +1725,5 @@
     // get cluster and local pointer on process
     process_cxy = GET_CXY( process_xp );
-    process_ptr = (process_t *)GET_PTR( process_xp );
+    process_ptr = GET_PTR( process_xp );
 
     // get extended pointer on stdin pseudo file
@@ -1831,8 +1752,9 @@
             current_ptr = GET_PTR( current_xp );
             parent_xp   = hal_remote_lwd( XPTR( current_cxy , &current_ptr->parent_xp ) );
-
             parent_cxy  = GET_CXY( parent_xp );
             parent_ptr  = GET_PTR( parent_xp );
             ppid        = hal_remote_lw( XPTR( parent_cxy , &parent_ptr->pid ) );
+
+printk("\n@@@ %s : pid = %x / process = %x\n", __FUNCTION__ , current_ptr->pid, current_ptr );
 
             if( ppid == 1 )  // current is KSH
@@ -1849,3 +1771,59 @@
 
 
-     
+//////////////////////////////////////////////////////     
+inline pid_t process_get_txt_owner( uint32_t channel )
+{
+    xptr_t      txt_rx_xp  = chdev_dir.txt_rx[channel];
+    cxy_t       txt_rx_cxy = GET_CXY( txt_rx_xp );
+    chdev_t *   txt_rx_ptr = GET_PTR( txt_rx_xp );
+
+    xptr_t process_xp = (xptr_t)hal_remote_lwd( XPTR( txt_rx_cxy, 
+                                                &txt_rx_ptr->ext.txt.owner_xp ) );
+
+    cxy_t       process_cxy = GET_CXY( process_xp );
+    process_t * process_ptr = GET_PTR( process_xp );
+
+    return (pid_t)hal_remote_lw( XPTR( process_cxy , &process_ptr->pid ) );
+}
+
+///////////////////////////////////////////
+void process_txt_display( uint32_t txt_id )
+{
+    xptr_t      chdev_xp;
+    cxy_t       chdev_cxy;
+    chdev_t   * chdev_ptr;
+    xptr_t      root_xp;
+    xptr_t      lock_xp;
+    xptr_t      current_xp;
+    xptr_t      iter_xp;
+
+    // check terminal index
+    assert( (txt_id < LOCAL_CLUSTER->nb_txt_channels) ,
+    __FUNCTION__ , "illegal TXT terminal index" );
+
+    // get pointers on TXT_RX[txt_id] chdev
+    chdev_xp  = chdev_dir.txt_rx[txt_id];
+    chdev_cxy = GET_CXY( chdev_xp );
+    chdev_ptr = GET_PTR( chdev_xp );
+
+    // get extended pointer on root & lock of attached process list
+    root_xp = XPTR( chdev_cxy , &chdev_ptr->ext.txt.root );
+    lock_xp = XPTR( chdev_cxy , &chdev_ptr->ext.txt.lock );
+
+    // display header
+    printk("\n***** processes attached to TXT_%d\n", txt_id );
+
+    // get lock
+    remote_spinlock_lock( lock_xp );
+
+    // scan attached process list to find KSH process
+    XLIST_FOREACH( root_xp , iter_xp )
+    {
+        current_xp  = XLIST_ELEMENT( iter_xp , process_t , txt_list );
+        process_display( current_xp );
+    }
+
+    // release lock
+    remote_spinlock_unlock( lock_xp );
+
+}  // end process_txt_display
