Starting from:
$35

$29

Systems Programming Assignment 3

Exercise:

Write a program “monitor1” and “monitor2”.

Both fork a child process.

The child process (for both):

The child process should read a file name from the keyboard and print the files information gathered with stat. If no file was found with that name, report this back to the user and wait for the next user input.

Entering “list” lists the content of the current directory (wherever the executable is being called in. Check: opendir, readdir and closedir).

Entering “q” ends the program (all processes).

Make the use of it in the shell visible with:

stat prog $

instead of “just” a cursor for the scanf.

“stat prog” should be blue and “$” standard text color.

“stat prog” is just the name of the program, as it it nicer to print something before the scanf to indicate where the user is – there is not more to it. You can also print:

my supergreat fancy program assignment three$

and when you want to print the work directory as well its something like:

myprogramname ../blabla/blablabla/$

The parent process of monitor1:

The parent should check every 10 seconds, if the child was active. If not, kill (brutally) the child and then end the parent program.

Prevent both process to be killed or terminated.
Right after the “kill” function in the parent, make sure to wait or you end up having a zombie.


The parent process of monitor2:

The parent should wait(0) for the child process to terminate.

After 10 seconds, the parent should fork the child again.










How we test

We run your code and wait for termination (in monitor1) and try to kill the child process (in monitor2).

Submission:

Submit the two source code files and the executables: MYNAME_signals_ass3.zip

Bonus

2% on your final grade if you can change directories:
“..” should go one level back.

“/foldername” should go into the folder. Report if the folder does not exists.

Report the current working folder to your scanf line: stat prog ./CURRENTFOLDER$

Use getcwd().

More products