Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check status of process

Tags:

c#

.net

I want to programmatically verify the status of an application to see if it has crashed or stopped. I know how to see if the process exists in C# but can I also see if it is "Not responding"?

like image 712
Niklas Winde Avatar asked Nov 26 '08 13:11

Niklas Winde


People also ask

How will you check the status of a process in Linux?

You can list running processes using the ps command (ps means process status). The ps command displays your currently running processes in real-time. This will display the process for the current shell with four columns: PID returns the unique process ID.

How can I check PID process status?

The easiest way to find out if process is running is run ps aux command and grep process name. If you got output along with process name/pid, your process is running.

How do I see what processes are running in Unix?

Open the terminal window on Unix. For remote Unix server use the ssh command for log in purpose. Type the ps aux command to see all running process in Unix. Alternatively, you can issue the top command to view running process in Unix.

What is ps EF command in Linux?

The “-ef” option of the “ps” command is used to print all the processes running on the system in the standard format.


1 Answers

Everything you need is in System.Diagnostics, for example: to check if a process is responding.

using System;
using System.Diagnostics;

namespace ProcessStatus
{
    class Program
    {
        static void Main(string[] args)
        {
            Process[] processes = Process.GetProcesses();

            foreach (Process process in processes)
            {
                Console.WriteLine("Process Name: {0}, Responding: {1}", process.ProcessName, process.Responding);
            }

            Console.Write("press enter");
            Console.ReadLine();
        }
    }
}
like image 185
Student for Life Avatar answered Nov 15 '22 18:11

Student for Life