Changeset 441 for trunk/user/ksh


Ignore:
Timestamp:
May 9, 2018, 3:13:56 PM (6 years ago)
Author:
alain
Message:

Fix a bug in rpc_vmm_get_pte_client() function (bad RPC index).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/user/ksh/ksh.c

    r440 r441  
    395395        int                  ret_exec;           // return value from exec
    396396    unsigned int         ksh_pid;            // KSH process PID
    397     unsigned int         new_pid;            // new process PID
    398     unsigned int         rcv_pid;            // terminating process PID
    399397        char               * pathname;           // path to .elf file
    400398    unsigned int         background;         // background execution if non zero
     
    425423    else if (ret_fork == 0)      // it is the CHILD process
    426424    {
    427         // give back to KSH terminal ownership if required
    428         if( background ) fg( ksh_pid );
    429 
    430425        // CHILD process exec NEW process
    431426        ret_exec = exec( pathname , NULL , NULL );
    432427
     428        // this is only executed in case of exec failure
    433429        if( ret_exec )
    434430        {
    435             printf("  error: new process unable to exec <%s>\n", pathname );
    436             return;
     431            printf("  error: child process unable to exec <%s>\n", pathname );
     432            exit( 0 );
    437433        }   
    438434        }
    439435    else                        // it is the parent KSH : ret_fork is the new process PID
    440436    {
    441         new_pid = ret_fork;
    442 
    443         // wait new process completion
    444         rcv_pid = wait( &status );
    445 
    446         if( rcv_pid == new_pid )
    447         {
    448             printf("\n\n   %s normal termination / status = %x\n\n",
    449             pathname , (status &0xFF) );
    450             return;
    451         }
    452         else
    453         {
    454             printf("\n\n   %s abnormal termination / status = %x\n\n",
    455             pathname , (status &0xFF) );
    456             return;
    457         }
     437        // give back terminal ownership to KSH if new process created in background /
     438        // wait new process completion before returning to command interpreter otherwise
     439        if( background )   fg( ksh_pid );
     440        else               wait( &status );
     441
     442        // return to command interpreter
     443        return;
    458444    }
    459445}   // end cmd_load
     
    758744                                                printf("# ");
    759745                                        }
     746                    else
     747                    {
     748                        printf("\n# ");
     749                    }
    760750                                }
    761751                                else if (c == '\t')     // tabulation => do nothing
Note: See TracChangeset for help on using the changeset viewer.