Question: /tmp/datafile contains lowercase alphabet: abcdefghijklmnopqrstuvwxyz program executes code fragment below. Assume all function calls are successful and parents wait() for the child blocks parent until
/tmp/datafile contains lowercase alphabet: abcdefghijklmnopqrstuvwxyz
program executes code fragment below. Assume all function calls are successful and parents wait() for the child blocks parent until child exits.
what best describes the output of the program? a. bbac b. babb c. adcd d. babc e. string cant be determined f. none of the above

int fd; char ch; fd=open("/tmp/datafile", O_RDWR); read(fd,&ch,1); read(fd,&ch, 1); if(fork()==0X fd=open(/tmp/datafile", O_RDWR); write(1,&ch,1); read(fd,&ch,1); write(1,&ch,1); read(fd,&ch,1); exit(0); } wait(NULL); write(1,&ch,1); read(fd,&ch,1); write(1,&ch,1); exit(0)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
