I would know how write a function that chows the state of a processus;its argument is PID of a processus
thank you!!
What do you mean by "state"? If you want to know about a process, you can type 'top' in the terminal
If I use the terminal; I know the method: cd/proc/PID then cat status
The second line of this file shows the state of the processus(running-zombie-...)
but I want write a programm C that contains a function,its argument is PID of processus
A PID is just a number identifier. Your function can simply be foo(unsigned int pid)

Or you can use the pid_t in sys/types.
I prefer to use the type pid_t
the role of my function is open the file /proc/PID/status and display the state of one processus that exists in the second line. The calling processus should display its state by using this function.
after this; the parent processus should create a child processus, the child processus should display the state of its parent and it ends.
the parent processus should display the state of its child,then it retrieves the return value of its child by using the primitive wait() and display the state of its child ,finally it ends.

How can write a program to do this????? ANY HELP!!!
You described reasonably well what to do. So I don't really understand what's your problem. Don't you know:
- How to open, read and write from/to a file?
- How to fork of a child? (man fork)
- How to terminate a process? (man exit)
- How to get a process pid? (man getpid)
- Surely wait(2) seems not to be your problem.
Topic archived. No new replies allowed.