To end the process, UNIX systems use the _ exit () system call. Consider
implementing this system call in Linux. The following actions occur during
its execution.
1.
The status of the process shines through TASK _ ZOMBIE
2.
The process informs the ancestors
and descendants that it has
ended (with the help of special signals)
3.
The resources allocated during the fork () call are released
4.
The scheduler is informed that
the context can be switched
You can use either the _ exit () system call or its exit () library function to
complete the process in applications. This function closes all process
threads, correctly
releases all resources, and calls _ exit ( ) to actually
complete it:
#include
void _exit (int status); // status specifies the return cod e
#include
void exit (int status); // status specifies the return code
exit (128);
Note that it is better not to call exit () when a process can use resources in
conjunction with other processes (for example, it is a descendant process
with an ancestor, and a descendant inherited resource descriptors from the
ancestor). The reason is that in this case, trying to release the resources in
the offspring will result in them being released from the ancestors as
well. You must use _ exit () to complete these processes.
Waiting For Process To Complete
When
the process is completed, its control block is not immediately
removed from the process list and hash and
remains there until another
process (ancestor) removes it from there. If the process is actually missing
in the system (it is finished), but only its control unit,
then the process is
called a
zombie process .