----------------------------------------------------------------
Print your name and SSN:
----------------------------------------------------------------
Question 1 (40 points)
The ps command of UNIX produces several lines each line corresponds to one process. E.g.,
% ps PID TTY TIME CMD 9004 pts/29 0:01 xterm 9005 pts/29 0:04 xterm 9006 pts/29 0:01 xterm 8985 pts/29 0:01 tcsh 12357 pts/29 0:05 netscape
To terminate a process, we normally find the corresponding process PID and then use the kill command. E.g., to kill netscape process in the above example, we may do the following:
% kill 12357
Use the Motif program chooseone (ch4 of Young textbook) to display the output of ps in a selection widget and then kill the selected process.
HINT: you may use the tr (translate characters) program to translate the spaces in each line of the ps output with some special character (e.g., +) so that each line can be treated as one item. If you are not familiar with tr, here is an example of its use:
% echo cs476+assignments+a1 | tr "+" "." cs476.assignments.a1
Question2 (30 points)
Write an Xlib program to with the following description:
NAME
OP - Order Pizza
SYNOPSIS
OP d1 d2 ...dn
DESCRIPTION
d1, d2, ...dn are display values (e.g., pitfall:0), and n is between 1 and 6.
The program creates a simple interface composed of a main window containing
the message:
"Would you like to eat Pizza?"
and two small children windows labeled "YES" and "NO".
Each user may respond to this question by clicking the left button
(and only the left button) on either the YES or NO windows.
The interface is destroyed immediately after the user enters his/her response.
When all users have answered the question
the program displays the result on the stdout of the initiator as follows:
YES n
No m
where n is the number of YESs
m is the number of NOs
Question3 (30 points)
Write a Motif program to display the output
of the unix "date" command as the label for a push button.
Whenever the user clicks on the push button the label is changed
to reflect the current date.