Changeset 441 for trunk/user/ksh
- Timestamp:
- May 9, 2018, 3:13:56 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/user/ksh/ksh.c
r440 r441 395 395 int ret_exec; // return value from exec 396 396 unsigned int ksh_pid; // KSH process PID 397 unsigned int new_pid; // new process PID398 unsigned int rcv_pid; // terminating process PID399 397 char * pathname; // path to .elf file 400 398 unsigned int background; // background execution if non zero … … 425 423 else if (ret_fork == 0) // it is the CHILD process 426 424 { 427 // give back to KSH terminal ownership if required428 if( background ) fg( ksh_pid );429 430 425 // CHILD process exec NEW process 431 426 ret_exec = exec( pathname , NULL , NULL ); 432 427 428 // this is only executed in case of exec failure 433 429 if( ret_exec ) 434 430 { 435 printf(" error: newprocess unable to exec <%s>\n", pathname );436 return;431 printf(" error: child process unable to exec <%s>\n", pathname ); 432 exit( 0 ); 437 433 } 438 434 } 439 435 else // it is the parent KSH : ret_fork is the new process PID 440 436 { 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; 458 444 } 459 445 } // end cmd_load … … 758 744 printf("# "); 759 745 } 746 else 747 { 748 printf("\n# "); 749 } 760 750 } 761 751 else if (c == '\t') // tabulation => do nothing
Note: See TracChangeset
for help on using the changeset viewer.