How do i know, if a process has completed its execution without any errors? How do i know, if a C++ program has returned success to OS?
If i run it via shell, then i
When a process terminates its parent process must acknowledge this using the wait
or waitpid
function. These functions also return the exit status. After the call to wait
or waitpid
the process table entry is removed, and the exit status is no longer stored anywhere in the operating system. You should check if the software you use to start the process saves the exit status somewhere.
If the parent process has not acknowledged that the child has terminated you can read its exit status from the /proc
file system: it is the last field in /proc/[pid]/stat
. It is stored in the same format that wait
returns it, so you have to divide by 256 to get the exit code. Also you probably have to be root.