Changeset 421 for trunk/kernel/syscalls/sys_kill.c
- Timestamp:
- Jan 29, 2018, 5:40:34 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/syscalls/sys_kill.c
r416 r421 38 38 { 39 39 uint32_t save_sr; // required to enable IRQs 40 xptr_t process_xp; // extended pointer on target reference process 41 cxy_t process_cxy; // target process cluster 42 process_t * process_ptr; // local pointer on target process 43 xptr_t parent_xp; // extended pointer on parent process 44 cxy_t parent_cxy; // parent process cluster 45 process_t * parent_ptr; // local pointer on parent process 46 pid_t ppid; // parent process PID 40 47 41 48 thread_t * this = CURRENT_THREAD; … … 49 56 #endif 50 57 51 // get owner process cluster and lpid 52 cxy_t owner_cxy = CXY_FROM_PID( pid ); 53 lpid_t lpid = LPID_FROM_PID( pid ); 58 // get cluster and pointers on reference process 59 process_xp = cluster_get_reference_process_from_pid( pid ); 60 process_cxy = GET_CXY( process_xp ); 61 process_ptr = (process_t *)GET_PTR( process_xp ); 54 62 55 // check p id56 if( (lpid >= CONFIG_MAX_PROCESS_PER_CLUSTER) || cluster_is_undefined( owner_cxy ))63 // check process existence 64 if( process_xp == XPTR_NULL ) 57 65 { 58 printk("\n[ERROR] in %s : illegal target PID = %d for thread %x in process %x\n", 59 __FUNCTION__ , pid , this->trdid , pid ); 66 syscall_dmsg("\n[ERROR] in %s : process %x not found\n", 67 __FUNCTION__ , pid ); 68 this->errno = EINVAL; 69 return -1; 70 } 71 72 // get parent process PID 73 parent_xp = hal_remote_lwd( XPTR( process_cxy , &process_ptr->parent_xp ) ); 74 parent_cxy = GET_CXY( parent_xp ); 75 parent_ptr = GET_PTR( parent_xp ); 76 ppid = hal_remote_lw( XPTR( parent_cxy , &parent_ptr->pid ) ); 77 78 // processes INIT and processes KSH cannot be stoped or killed 79 if( ppid < 2 ) 80 { 81 syscall_dmsg("\n[ERROR] in %s : process %x cannot be killed\n", 82 __FUNCTION__ , pid ); 60 83 this->errno = EINVAL; 61 84 return -1; 62 85 } 63 86 87 // does nothing if sig_id == 0 88 if( sig_id == 0 ) return 0; 89 64 90 // check sig_id 65 91 if( (sig_id != SIGSTOP) && (sig_id != SIGCONT) && (sig_id != SIGKILL) ) 66 92 { 67 printk("\n[ERROR] in %s : illegal signal type for thread %x inprocess %x\n",68 __FUNCTION__ , sig_id , this->trdid ,pid );93 syscall_dmsg("\n[ERROR] in %s : illegal signal type for process %x\n", 94 __FUNCTION__ , sig_id , pid ); 69 95 this->errno = EINVAL; 70 96 return -1; … … 75 101 76 102 // execute process_make_kill() function in owner cluster 77 if( local_cxy == owner_cxy ) // owner is local103 if( local_cxy == process_cxy ) // owner cluster is local 78 104 { 79 105 process_make_kill( pid , sig_id ); 80 106 } 81 else // owner is remote107 else // owner cluster is remote 82 108 { 83 rpc_process_make_kill_client( owner_cxy , pid , sig_id );109 rpc_process_make_kill_client( process_cxy , pid , sig_id ); 84 110 } 85 111
Note: See TracChangeset
for help on using the changeset viewer.