Changeset 435 for trunk/kernel/syscalls/sys_kill.c
- Timestamp:
- Feb 20, 2018, 5:32:17 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/syscalls/sys_kill.c
r433 r435 48 48 49 49 thread_t * this = CURRENT_THREAD; 50 process_t * process = this->process; 50 51 51 52 #if CONFIG_DEBUG_SYS_KILL … … 58 59 #endif 59 60 60 // get cluster and pointers on owner process 61 // process cannot kill itself 62 if( pid == process->pid ) 63 { 64 65 #if CONFIG_DEBUG_SYSCALLS_ERROR 66 printk("\n[ERROR] in %s : process %d cannot kill itself\n", __FUNCTION__ , pid ); 67 #endif 68 this->errno = EINVAL; 69 return -1; 70 } 71 72 // get cluster and pointers on owner target process descriptor 61 73 owner_xp = cluster_get_owner_process_from_pid( pid ); 62 74 owner_cxy = GET_CXY( owner_xp ); … … 67 79 { 68 80 69 syscall_dmsg("\n[ERROR] in %s : process %x not found\n", __FUNCTION__ , pid ); 70 81 #if CONFIG_DEBUG_SYSCALLS_ERROR 82 printk("\n[ERROR] in %s : process %x not found\n", __FUNCTION__ , pid ); 83 #endif 71 84 this->errno = EINVAL; 72 85 return -1; … … 79 92 ppid = hal_remote_lw( XPTR( parent_cxy , &parent_ptr->pid ) ); 80 93 81 // processes INIT and processes KSH cannot be stoped or killed82 if( p pid < 2)94 // processes INIT 95 if( pid == 1 ) 83 96 { 84 97 85 syscall_dmsg("\n[ERROR] in %s : process %x cannot be killed\n", __FUNCTION__ , pid ); 86 98 #if CONFIG_DEBUG_SYSCALLS_ERROR 99 printk("\n[ERROR] in %s : process_init cannot be killed\n", __FUNCTION__ ); 100 #endif 87 101 this->errno = EINVAL; 88 102 return -1; … … 92 106 hal_enable_irq( &save_sr ); 93 107 94 // analyse signal type 95 // supported values are : 0, SIGSTOP, SIGCONT, SIGKILL 108 // analyse signal type / supported values are : 0, SIGSTOP, SIGCONT, SIGKILL 96 109 switch( sig_id ) 97 110 { … … 108 121 109 122 // block all threads in all clusters 110 process_sigaction( owner_ptr, BLOCK_ALL_THREADS );123 process_sigaction( pid , BLOCK_ALL_THREADS ); 111 124 112 // atomically update referenceprocess termination state125 // atomically update owner process termination state 113 126 hal_remote_atomic_or( XPTR( owner_cxy , &owner_ptr->term_state ) , 114 PROCESS_ FLAG_BLOCK);127 PROCESS_TERM_STOP ); 115 128 116 129 retval = 0; … … 120 133 { 121 134 // unblock all threads in all clusters 122 process_sigaction( owner_ptr, UNBLOCK_ALL_THREADS );135 process_sigaction( pid , UNBLOCK_ALL_THREADS ); 123 136 124 137 // atomically update reference process termination state 125 138 hal_remote_atomic_and( XPTR( owner_cxy , &owner_ptr->term_state ) , 126 ~PROCESS_ FLAG_BLOCK);139 ~PROCESS_TERM_STOP ); 127 140 retval = 0; 128 141 break; … … 131 144 case SIGKILL: 132 145 { 133 // the process_make_kill() function must be executed 134 // by an RPC thread in process owner cluster 135 // It deletes all target process threads in all clusters, 136 // and updates the process termination state 137 rpc_process_make_kill_client( owner_cxy , owner_ptr , false , 0 ); 146 // remove TXT ownership from owner process descriptor 147 process_txt_reset_ownership( owner_xp ); 148 149 // block all process threads in all clusters 150 process_sigaction( pid , BLOCK_ALL_THREADS ); 151 152 // mark all process threads in all clusters for delete 153 process_sigaction( pid , DELETE_ALL_THREADS ); 154 155 // atomically update owner process descriptor flags 156 hal_remote_atomic_or( XPTR( owner_cxy , &owner_ptr->term_state ) , 157 PROCESS_TERM_KILL ); 138 158 139 159 retval = 0; … … 143 163 { 144 164 145 syscall_dmsg("\n[ERROR] in %s : illegal signal type %d for process %x\n", 146 __FUNCTION__ , sig_id, pid );147 165 #if CONFIG_DEBUG_SYSCALLS_ERROR 166 printk("\n[ERROR] in %s : illegal signal %d / process %x\n", __FUNCTION__, sig_id, pid ); 167 #endif 148 168 this->errno = EINVAL; 149 169 retval = -1;
Note: See TracChangeset
for help on using the changeset viewer.