New version page

UConn CSE 2102 - Lab 5

Documents in this Course
Load more

Previewing page 1


Unformatted text preview:

CSE 3100 Systems Programming Fall 2018Lab #5Welcome to Lab 5! This lab assignment is due 36 hours after your lab session starts. For example,if your lab session starts at 8am on Friday, the assignment is due at 8pm on Saturday.Read each question carefully before beginning work. Start by executing git pull inside your Git repos-itory on the virtual machine. Remember to add, commit, and push when you complete your work. AddONLY *.c to the git repo. Do not add .o files or executables.You will be working on invoke-editor.c for both problems.Part 1: invoke-editor uses fork() and one of the exec functions to start an editor to edit a file specifiedat the command line. If no file name is specified, the program uses a default file name. The parent processwaits for the child process to exit and prints out the exit status of the child process using the followingformat string:"pid=%d exited=%d exitstatus=%d\n"The first number is the PID of the child process, the second number is from WIFEXITED, and the thirdis from WEXITSTATUS. Study the demo code or the manuals to learn WIFEXITED and WEXITSTATUS.You can change the editor from vi to either nano or emacs.Pick an exec function that searches for the executable in directories in PATH.Part 2: Filter lines. After the child process ends, the parent process opens the same file and prints outthe lines that start with ’#’. You must use C library functions declared in stdio.h, for example, fopen(),fgetc(), and fgets(), to operate on the file. Pick the functions you think are best for the problem.Some sample sessions are shown below. You do not need to change files in the editor.$ ./invoke-editor Makefilepid=7276 exited=1 exitstatus=0# define more variables so it is easier to make changes# again, study the new variables and rules#Static Pattern Rules$ % ./invoke-editor invoke-editor.cpid=7306 exited=1 exitstatus=0#define _POSIX_C_SOURCE 1#include <stdlib.h>#include <stdio.h>#include <unistd.h>#include <string.h>#include <sys/types.h>#include


View Full Document
Loading Unlocking...
Login

Join to view Lab 5 and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lab 5 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?