Junior — Middle
Who is responsible for terminating and freeing process resources in the operating system?
sobes.tech AI
Answer from AI
In the operating system, the scheduler and the memory management subsystem are responsible for process termination and resource release.
When a process terminates, the OS:
- Frees the memory allocated to the process (heap, stack, code, and data segments).
- Closes open files and descriptors.
- Removes process records from process tables.
In Unix-like systems, the parent process usually receives a notification of the child's termination (via the SIGCHLD signal) and calls the wait() system call to obtain the termination status and free resources.
If the parent does not call wait(), the process may become a zombie, holding onto some resources.
Thus, the OS, together with the parent process, manages proper termination and resource cleanup.