| OLD | NEW |
| 1 /* | 1 /* |
| 2 * $Id: process_info.c 1142 2011-10-05 18:45:49Z g.rodola $ | 2 * $Id: process_info.c 1187 2011-10-22 15:56:59Z g.rodola $ |
| 3 * | 3 * |
| 4 * Copyright (c) 2009, Jay Loden, Giampaolo Rodola'. All rights reserved. | 4 * Copyright (c) 2009, Jay Loden, Giampaolo Rodola'. All rights reserved. |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 * | 7 * |
| 8 * Helper functions related to fetching process information. Used by _psutil_bsd | 8 * Helper functions related to fetching process information. Used by _psutil_bsd |
| 9 * module methods. | 9 * module methods. |
| 10 */ | 10 */ |
| 11 | 11 |
| 12 #include <Python.h> | 12 #include <Python.h> |
| 13 #include <assert.h> | 13 #include <assert.h> |
| 14 #include <errno.h> | 14 #include <errno.h> |
| 15 #include <stdlib.h> | 15 #include <stdlib.h> |
| 16 #include <stdio.h> | 16 #include <stdio.h> |
| 17 #include <string.h> | 17 #include <string.h> |
| 18 #include <sys/types.h> | 18 #include <sys/types.h> |
| 19 #include <sys/sysctl.h> | 19 #include <sys/sysctl.h> |
| 20 #include <sys/param.h> | 20 #include <sys/param.h> |
| 21 #include <sys/user.h> | 21 #include <sys/user.h> |
| 22 #include <sys/proc.h> | 22 #include <sys/proc.h> |
| 23 #include <signal.h> |
| 23 | 24 |
| 24 #include "process_info.h" | 25 #include "process_info.h" |
| 25 | 26 |
| 26 | 27 |
| 27 /* | 28 /* |
| 28 * Returns a list of all BSD processes on the system. This routine | 29 * Returns a list of all BSD processes on the system. This routine |
| 29 * allocates the list and puts it in *procList and a count of the | 30 * allocates the list and puts it in *procList and a count of the |
| 30 * number of entries in *procCount. You are responsible for freeing | 31 * number of entries in *procCount. You are responsible for freeing |
| 31 * this list (use "free" from System framework). | 32 * this list (use "free" from System framework). |
| 32 * On success, the function returns 0. | 33 * On success, the function returns 0. |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 // if kill returns success of permission denied we know it's a valid PID | 262 // if kill returns success of permission denied we know it's a valid PID |
| 262 kill_ret = kill(pid , 0); | 263 kill_ret = kill(pid , 0); |
| 263 if ((0 == kill_ret) || (EPERM == errno)) { | 264 if ((0 == kill_ret) || (EPERM == errno)) { |
| 264 return 1; | 265 return 1; |
| 265 } | 266 } |
| 266 | 267 |
| 267 // otherwise return 0 for PID not found | 268 // otherwise return 0 for PID not found |
| 268 return 0; | 269 return 0; |
| 269 } | 270 } |
| 270 | 271 |
| OLD | NEW |