Operating System Ubuntu 1804 Csimpleshellc 1 Csimpleshellc Enrico Franchi 2005 2 Https Web Q43907994
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: minor changes to eliminate most compilation warnings 7 (Anil Somayaji, soma@scs.carleton.ca) 8 */ 9 10 #include <stdio.h>11 #include <stdlib.h>12 #include <unistd.h>13 #include <string.h>14 #include <errno.h>15 #include <sys/wait.h>16 #include <sys/types.h>17 #define BUFFER_SIZE 1<<1618 #define ARR_SIZE 1<<1619 20 void parse_args(char *buffer, char** args, 21 size_t args_size, size_t *nargs)22 {23 char *buf_args[args_size]; /* You need C99 */24 char **cp;25 char *wbuf;26 size_t i, j;27 28 wbuf=buffer;29 buf_args[0]=buffer; 30 args[0] =buffer;31 32 for(cp=buf_args; (*cp=strsep(&wbuf, ” nt”)) != NULL ;){33 if ((*cp != NULL) && (++cp >= &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)n”, pid);65 pid = wait(&ret_status);66 printf(“Child (%d) finishedn”, 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? Show transcribed image text Download, compile, and run csimpleshell.ce. How does its functionality compare to that of bash?
Expert Answer
Answer to The operating system is Ubuntu 18.04 csimpleshell.c 1 /* csimpleshell.c, Enrico Franchi © 2005 2 https://web.archive.or…
OR