Processos =/
Boa tarde pessoal!!
estou com um enorme problema.. sou nova no linux, e o meu professor da cadeira de sistemas operativos apenas nos tem ensinado a teorica, e tenho um projecto para entregar esta semana e estou mesmo aflita!!
o trabalho é o seguinte:
Write a program, that creates 3 processes which are in relation grandfather -> father -> child.
Each of that processes prints information about itself to stdout using following format after start:
printf("%s identification: \n", label); /*grandparent/parent/child */
printf(" pid = %d, ppid = %d, pgrp = %d\n", ...);
printf(" uid = %d, gid = %d\n", ...);
printf(" euid = %d, egid = %d\n", ...);
After lunching its child (first 2 processes) the process waits for that child end and prints reason for termination of the child:
printf("%s exit (pid = %d):", label, ...); /* and one line from */
printf(" normal termination (exit code = %d)\n", ...); /* or */
printf(" signal termination %s(signal = %d)\n", ...); /* or */
printf(" unknown type of termination\n");
Mask "%s" on line with information about interruption of program with signal will be replaced either with empty string or with string "with core dump ". Use following macros to test the reason of termination of the child: WIFEXITED(), WEXITSTATUS(), WIFSIGNALED(), WCOREDUMP(), WTERMSIG(). Child (the third process) after printing information about itself run a program (function execv()), whose name with absolute path is placed as first parameter of your program. The program to be executed can have other parameters that are taken from command line (any number of them and it is not necessary to copy anything).
To start with the project check base.tar.gz*. For compilation use the -Wall option and the definition of _XOPEN_SOURCE and _XOPEN_SOURCE_EXTENDED macros. Makro WCOREDUMP does not have to be defined on all systems so its use must be checked with
#ifdef WCOREDUM
...use of WCOREDUMP...
#endif
With this example your program will run /bin/ls in third process and pass -l /bin/bash as its parameters.
./proj01 /bin/ls -l /bin/bash
*#define _XOPEN_SOURCE
#define _XOPEN_SOURCE_EXTENDED 1 /* XPG 4.2 - needed for WCOREDUMP() */
/* ARGSUSED */
int main(int argc, char *argv[])
{
return 0;
}
já alguém fez um projecto destes ou tem código por onde eu me possa orientar?!
Obrigado!!