Write and test a C program to check the processor status suc
Write and test a C program to check the processor status such as processes running on the system.
Solution
#include <sys/types.h>
 #include <sys/wait.h>
int status;
 pid_t return_pid = waitpid(process_id, &status, WNOHANG);
 if (return_pid == -1) {
    printf(\"error in getting process\");
 } else if (return_pid == 0) {
    printf(\"process is still running\");
 } else if (return_pid == process_id) {
    printf(\"process finished\")
 }

