Processes (ITS8020)

Allikas: Kursused
Redaktsioon seisuga 19. oktoober 2018, kell 08:40 kasutajalt Irve (arutelu | kaastöö) (Uus lehekülg: '{{its8020}} ''We look at ways to execute a program'' The goal of the lab is to use three different programs to see how to execute programs. It's really simple this time. == Tas...')
(erin) ←Vanem redaktsioon | Viimane redaktsiooni (erin) | Uuem redaktsioon→ (erin)
Mine navigeerimisribale Mine otsikasti

We look at ways to execute a program

The goal of the lab is to use three different programs to see how to execute programs. It's really simple this time.

Task

Write three programs.

First one -- execute -- runs the program "stopper" (you can find it in the prototype below) with argument "-s" from the same directory where it is located (use only exec()).

The second -- runner -- runs program "stopper" with argument "-s" from the same directory where it is located and waits for it to finish. After the program has concluded, it prints "runner: Stopped". (fork() + exec() + wait())

Third program -- backgrounder -- runs the program "stopper" with an argument of "-s", but does not wait for it to conclude; it exits. This would be analogous to the Daemon pattern explained in the lecture.

Backgrounder should print the PID of itself and the child when it runs.

NB! If you want to compile only the first program, write "make stopper" or "make runner".

Prototype

The prototype can be found at /export/kursused/iti8510/ (or [1] ) To copy the file to the current directory:

cp /export/kursused/iti8510/processes.tar.gz .

Untar it:

tar -xzvf processes.tar.gz