Ignore:
Timestamp:
Jan 29, 2018, 5:40:34 PM (6 years ago)
Author:
alain
Message:

Introduce sys_fg() , sys_display() , sys_wait() syscalls.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/syscalls/sys_kill.c

    r416 r421  
    3838{
    3939    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
    4047
    4148    thread_t  * this    = CURRENT_THREAD;
     
    4956#endif
    5057
    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 );
    5462
    55     // check pid
    56     if( (lpid >= CONFIG_MAX_PROCESS_PER_CLUSTER) || cluster_is_undefined( owner_cxy ) )
     63    // check process existence
     64    if( process_xp == XPTR_NULL )
    5765    {
    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 );
    6083                this->errno = EINVAL;
    6184        return -1;
    6285    }
    6386
     87    // does nothing if sig_id == 0
     88    if( sig_id == 0 )  return 0;
     89   
    6490    // check sig_id
    6591    if( (sig_id != SIGSTOP) && (sig_id != SIGCONT) && (sig_id != SIGKILL) )
    6692    {
    67         printk("\n[ERROR] in %s : illegal signal type for thread %x in process %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 );
    6995                this->errno = EINVAL;
    7096        return -1;
     
    75101
    76102    // execute process_make_kill() function in owner cluster
    77     if( local_cxy == owner_cxy )                                // owner is local
     103    if( local_cxy == process_cxy )                            // owner cluster is local
    78104    {
    79105        process_make_kill( pid , sig_id );
    80106    }
    81     else                                                        // owner is remote
     107    else                                                      // owner cluster is remote
    82108    {
    83         rpc_process_make_kill_client( owner_cxy , pid , sig_id );
     109        rpc_process_make_kill_client( process_cxy , pid , sig_id );
    84110    }
    85111
Note: See TracChangeset for help on using the changeset viewer.