/* CODE WILL TAKE A COMMAND, PASS IT TO CREATEPROCESS(), * FORK A CHILD AND EXECUTE COMMAND * * */ #include #include #include #include char* buffer; pid_t pid; void startProcess( char* ); int main () { char* input = (char*)malloc( 128 ); buffer = NULL; while( 1 ) { printf( "EECE315_Shell - %s$ ", getcwd(NULL, 0) ); gets( input ); if( strcmp(input, "exit") == 0 ) { printf( "Terminating shell...\n" ); return 0; } else if( strcmp(input, "") != 0 ) { startProcess( input ); } } } void startProcess( char* input ) { pid = fork(); if( pid == 0 ) { execvp( input, NULL ); } else if( pid > 0 ) { //parent wait } else { printf( "Fork returned error code, no child" ); } }