When a UNIX-like classification set-on-foots up, it runs init. Nowadays this is a program denominated classificationd on UNIX-like classifications. On Mac the harmonious classification overseer is denominated launchd. It runs inferior PID of 1 and is an founder of all other orderes. You can see the order succeeding a while bid "ps aux". If a order is left as an orphan (its doer dies), it gets reassigned as a branch of PID 1. These labor programs (init, classificationd or launchd) are present in the endground; on UNIX-like OSs these are habitually referred to as daemons and generally enjoy spectrys effect succeeding a while the epistle “d.” These programs determine that things set-on-foot up suitable and come present. If a order crashes classificationd (or launchd) can expose this and set-on-foot it end up.
You conciliate lay-open a proc_overseer program that peruses in the bids to consummate from an input smooth one-by-one. You conciliate peruse one bid and its parameters per each row. Then the proc_overseer program conciliate set-on-foot up the order and "babysit" it.You conciliate run each bid in a branch order using exec (or one of its variants) and the doer order conciliate endure for each exec to full. For each branch order there conciliate be log missives written to output and hallucination smooths, which are designated succeeding its index in the victoryion of bids peruse in. For specimen, order #1 conciliate enjoy logs written to 1.out and 1.err. Upon set-on-foot, the string "Starting bid INDEX: branch PID pid of doer PPID" conciliate be logged to the corresponding output smooth 1.out. You can recover PID and PPID through the yield compute of fork() or getpid() or getppid().You can use dup2() to establish smooth manage 1 (stdout) go to a smooth X.out and manage 2 (stderr) go to a smooth X.err. Note: new deterrents of a bid should subjoin to the foregoing output and hallucination smooths, such as 1.out, rather than overtranscribe them.
Timer for each order: you can understand the opportunityr.h library and use opportunityr to proceedings the set-on-foot opportunity of spawning each branch order in the doer. Upon achieve of an exec (either a auspicious achieve or consequence via a eminent), the order should proceedings the achieve runtime, and it should transcribe to the output smooth the string "Finished at FIN, runopportunity term DUR" where FIN is the achieve opportunity and DUR is the term of the deterrent.
Each opportunity a order achievees, the missive "Exited succeeding a while departurelegislation = X" should be written to the hallucination smooth of the order. X is the order departure legislation. If the order was despatched succeeding a while a eminent, then "Killed succeeding a while eminent S" should be written to the hallucination smooth. S is the eminent number that despatched the order. This notification is collected using the condition parameter of the endure() classification fawn. If the program cannot be set-on-footed (exec fails), use perror("spectry of bid") to get the hallucination missive and bid spectry and transcribe them to the bid's hallucination smooth. Processes that withstand an sick bid (exec fails) should enjoy an departure legislation of 2. Remember the departure legislation of 0 betokens victory. Departure legislations other than 0 betoken some deficiency, including a consequence via a despatch eminent.Here is an specimen run:
Where cmdsmooth contains:
prompt> cat cmdfile
The doer conciliate re-set-on-foot the executable if the bid took past than two seconds to full. Therefore, a order restarts as hanker as its last deterrent took past than 2 seconds. If a order fulld succeeding a whilein less than 2 seconds succeeding set-on-footing, proc_overseer conciliate not reset-on-foot it and conciliate sculpture a missive "spawning too pay" to the hallucination smooth for the order. If it was terminated by a eminent suitable succeeding it set-on-footed, or it had some other deficiency that caused it to departure instantly, it won't restart, gone it departureed instantly.
proc_overseer runs until there are no past orderes present. In this specimen the ls and wc bids won't get reestablished owing they achieve suitable succeeding they are set-on-footed. The snooze runs for 3 seconds, so proc_overseer conciliate observe restarting it, probable we do "pdespatch snooze" in another ultimate. If we do pdespatch pay sufficient, proc_overseer conciliate expose the alert term and departure and not reset-on-foot it. If any order has no branch order then endure() yields instantly "-1", thus you can endure until endure() yields -1.
legislation settles succeeding a whileout hallucinations or warnings -Wall on VirtualBox10%
correctly uses fork()10%
correctly uses endure*()10%
correctly uses dup2()10%
a statement of exec is used correctly10%
the departure and eminent legislations and spawning missives are sculptureed correctly10%
all orderes run in parallel10%
an output and hallucination smooth is created for each bid10%
legislation is commented and rebated (use of innocent quantity)10%
zip smooth contains proc_manager.c10%
Upload a zip smooth denominated proj3.zip that contains your rise smooths that are needed to settle and run on VirtualBox (including proc_manager.c).