Вопрос

I want the /proc/PID/ directory of a process to be conserved for some time even after the exit of the program ,so that its "grand parent" can check out the resource usage from /proc/PID/stat. I can't use wait4() since I am concerned about the resource usage of "grand cild". So how can I conserve the /proc/PID/ directory?

NOTE : Copying the /proc/PID/stat just before exiting the program is not a solution in my context,since I need the total resource usage statistics of that process throughout its life time.

Это было полезно?

Решение

The answer to your problem is probably to simply NOT have the grandchild exit when it is done. Instead it should tell the grandparent that it is done (via pipe or fifo or signal or even some shared memory channel is possible), so that the grandparent can get the info it needs from /proc/PID and then tell the grandchild to exit (again, any method can be used, but signal is probably the easiest).

Другие советы

You can't. /proc/PID is not a real directory -- it's constructed by the kernel to represent a running process. If the process doesn't exist, neither will that directory, and there's no way around that.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top