help pleas

:’(Goal: The goal of this program is to help you understand the process management concepts in UNIX.
Specically, you learn the usage of the following system calls:
fork(): process creation
exec(): replacing a process with another program
kill(): sending a signal to a process
signal(): registering/installing signal catch routines.
Program Description: You write two programs, called P1 and C1. P1 rst creates a process for C1 using
fork() and exec() system calls. After that, P1 continuously issues alarm() system calls and catches and
counts SIGALARM signal. In its SIGALARM catch routine, P1 sends a signal to the child process. The
child process counts the number of SIGALARM signals received from its parent. Upon reaching a specied
number, which is given as an argument in the exec() call, the child process reports the signal count and
terminates itself. The parent process, P1, should always check and report the status of its child. After
noticing its child termination, the parent should report the status of child process before it terminates itself.
Hint: when a child dies, the parent process receives SIGCHLD (or SIGCLD) signal.
Useful links with some programming examples:
Tutorials
http://www.erlenstar.demon.co.uk/unix/faq_toc.html
To see the set of all signals supported on your system, type, kill l (Note. el not number 1). For example,
the system on common machine supports the following signals.
%kill l
HUP INT QUIT ILL TRAP ABRT EMT FPE KILL BUS SEGV SYS PIPE ALRM TERM URG
STOP TSTP CONT CHLD TTIN TTOU IO XCPU XFSZ VTALRM PROF WINCH INFO USR1 USR2
RESV RTMIN RTMIN+1 RTMIN+2 RTMIN+3 RTMIN+4 RTMIN+5 RTMIN+6 RTMIN+7
RTMAX-7 RTMAX-6 RTMAX-5 RTMAX-4 RTMAX-3 RTMAX-2 RTMAX-1 RTMAX
A note about signals
When a Unix process receives a signal it can take one of three actions.
Take whatever default action is indicated by the signal. Often this means terminating the process with
or without a core dump. Note that some signals do not have a default action.
Trap the signal. Trapping a signal means that the program receives the signal and executes a special
subroutine called a signal handling routine. For example, if a text editor receives the INT
(interrupt program) signal, its signal handling routine may save backup then exit the editor. See
http://users.actcom.co.il/~choo/lupg/tutorials/signals/signalsprogramming.html to understand the usage
of signal() system call to associate a signal to a handling routine within a process.
Ignore the signal.
: : :
A sample code using signal to catch INT signal
#include <stdio.h> /* standard I/O functions /
#include <unistd.h> /
standard unix functions, like getpid() /
#include <signal.h> /
signal name macros, and the signal() prototype /
/
rst, here is the signal handler /
void catch_int(int sig_num)
{
/
re-set the signal handler again to catch_int, for next time /
signal(SIGINT, catch_int);
printf("Don’t do that
");
fflush(stdout);
}
int main(int argc, char
argv])
{
/* set the INT (Ctrl-C) signal handler to ’catch_int’ /
signal(SIGINT, catch_int);
/
now, lets get into an innite loop of doing nothing. /
for(;:wink:
pause();
}
: : :
A sample code using kill() to send a STOP signal to itself
#include <unistd.h> /
standard unix functions, like getpid() /
#include <sys/types.h> /
various type denitions, like pid_t /
#include <signal.h> /
signal name macros, and the kill() prototype /
/
rst, nd my own process ID /
pid_t my_pid = getpid();
/
now that i got my PID, send myself the STOP signal. */
kill(my_pid, SIGSTOP);
: : :

NOOOOOF wrote:
> :’(Goal: The goal of this program is to help you understand the process
> management concepts in UNIX.

-=welcome=- first time poster!

welcome to the openSUSE forum, where we like to help folks with their
openSUSE systems…

but, i don’t we do a lot of helping with basic UNIX programming homework…


DenverD
CAVEAT: http://is.gd/bpoMD [posted via NNTP w/openSUSE 10.3]

thanks alot
this is home work in subjct operating system
i hope to help me to solve it