Results 1 to 2 of 2
Hi,
I am writting a kernel module which needs to get a process status(running or not) according to its name(I know the name of the executive file)
Thanks in advance!...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 02-26-2013 #1Just Joined!
- Join Date
- Feb 2013
- Posts
- 2
how to get a process status according to process name in the kernel?
Hi,
I am writting a kernel module which needs to get a process status(running or not) according to its name(I know the name of the executive file)
Thanks in advance!
- 03-01-2013 #2Just Joined!
- Join Date
- Sep 2012
- Location
- Nashville, TN
- Posts
- 67
If it is a particual process that will never change get the pid location and just do a check for if the process.pid exists or not. If the service is off you should not see that file. If it is active you should be able to read that file and get the process id.
Here is an example of my apache server
Here you can see that the pid file gave me the parent process id.Code:[root@prodsimsfe logs]# ls access_log jk-runtime-status.2133 mod_jk.log cor_access_log jk-runtime-status.2133.lock ssl_access_log error_log jk-runtime-status.27178 ssl_error_log httpd.pid jk-runtime-status.27178.lock ssl_request_log jk-runtime-status.11341 jk-runtime-status.29142 jk-runtime-status.11341.lock jk-runtime-status.29142.lock [root@prodsimsfe logs]# cat httpd.pid 2133 [root@prodsimsfe logs]# ps -ef | grep httpd root 2133 1 0 Jan18 ? 00:01:21 /usr/local/apache2/bin/httpd daemon 7434 2133 0 Jan28 ? 00:00:00 /usr/local/apache2/bin/httpd daemon 7503 2133 0 Jan28 ? 00:00:00 /usr/local/apache2/bin/httpd daemon 30301 2133 0 00:03 ? 00:00:01 /usr/local/apache2/bin/httpd daemon 30374 2133 0 00:39 ? 00:00:00 /usr/local/apache2/bin/httpd daemon 30416 2133 0 00:53 ? 00:00:00 /usr/local/apache2/bin/httpd daemon 30431 2133 0 01:00 ? 00:00:00 /usr/local/apache2/bin/httpd daemon 30472 2133 0 01:10 ? 00:00:00 /usr/local/apache2/bin/httpd daemon 30524 2133 0 01:36 ? 00:00:00 /usr/local/apache2/bin/httpd daemon 30535 2133 0 01:40 ? 00:00:00 /usr/local/apache2/bin/httpd daemon 30537 2133 0 01:41 ? 00:00:00 /usr/local/apache2/bin/httpd daemon 30538 2133 0 01:41 ? 00:00:00 /usr/local/apache2/bin/httpd daemon 30612 2133 0 02:09 ? 00:00:00 /usr/local/apache2/bin/httpd root 30651 30626 0 02:12 pts/0 00:00:00 grep httpd [root@prodsimsfe logs]#


Reply With Quote
