Question: The operating system is Ubuntu 18.04 csimpleshell.c 1 /* csimpleshell.c, Enrico Franchi 2005 2 https://web.archive.org/web/20170223203852/ 3 http://rik0.altervista.org/snippets/csimpleshell.html 4 BSD license 5 6 January 12, 2019:

The operating system is Ubuntu 18.04

The operating system is Ubuntu 18.04 csimpleshell.c 1 /* csimpleshell.c, Enrico Franchi

csimpleshell.c

 1 /* csimpleshell.c, Enrico Franchi  2005 2 https://web.archive.org/web/20170223203852/ 3 http://rik0.altervista.org/snippets/csimpleshell.html 4 "BSD" license 5 6 January 12, 2019: minor changes to eliminate most compilation warnings 7 (Anil Somayaji, soma@scs.carleton.ca) 8 */ 9 10 #include  11 #include  12 #include  13 #include  14 #include  15 #include  16 #include  17 #define BUFFER_SIZE 1= &buf_args[args_size])) 34 break; 35 } 36 37 for (j=i=0; buf_args[i]!=NULL; i++){ 38 if(strlen(buf_args[i])>0) 39 args[j++]=buf_args[i]; 40 } 41 42 *nargs=j; 43 args[j]=NULL; 44 } 45 46 47 int main(int argc, char *argv[], char *envp[]){ 48 char buffer[BUFFER_SIZE]; 49 char *args[ARR_SIZE]; 50 51 int ret_status; 52 size_t nargs; 53 pid_t pid; 54 55 while(1){ 56 printf("$ "); 57 fgets(buffer, BUFFER_SIZE, stdin); 58 parse_args(buffer, args, ARR_SIZE, &nargs); 59 60 if (nargs==0) continue; 61 if (!strcmp(args[0], "exit" )) exit(0); 62 pid = fork(); 63 if (pid){ 64 printf("Waiting for child (%d) ", pid); 65 pid = wait(&ret_status); 66 printf("Child (%d) finished ", pid); 67 } else { 68 if( execvp(args[0], args)) { 69 puts(strerror(errno)); 70 exit(127); 71 } 72 } 73 } 74 return 0; 75 }

Download, compile, and run csimpleshell.ce. How does its functionality compare to that of bash

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!