summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2020-01-24 19:25:59 +0000
committerGiampaolo Rodola <g.rodola@gmail.com>2020-01-24 19:25:59 +0000
commit65b447f63880ebffdbd7522f09d436d2f0707d57 (patch)
treeead9322cc006d2ae079f5fc2e1dfbb3e796e3af5
parentcbbd95abdfdd0befbf665144e4edffa02dd86219 (diff)
downloadpsutil-65b447f63880ebffdbd7522f09d436d2f0707d57.tar.gz
conver pid from long to pid_t on FreeBSD
-rw-r--r--Makefile1
-rw-r--r--psutil/_psutil_bsd.c16
-rw-r--r--psutil/arch/freebsd/proc_socks.c2
-rw-r--r--psutil/arch/freebsd/specific.c22
4 files changed, 20 insertions, 21 deletions
diff --git a/Makefile b/Makefile
index 94fa3b24..890c6e41 100644
--- a/Makefile
+++ b/Makefile
@@ -15,7 +15,6 @@ DEPS = \
ipaddress \
mock==1.0.1 \
pyperf \
- readline \
requests \
setuptools \
sphinx \
diff --git a/psutil/_psutil_bsd.c b/psutil/_psutil_bsd.c
index f58cc72f..a20a8333 100644
--- a/psutil/_psutil_bsd.c
+++ b/psutil/_psutil_bsd.c
@@ -190,7 +190,7 @@ psutil_boot_time(PyObject *self, PyObject *args) {
*/
static PyObject *
psutil_proc_oneshot_info(PyObject *self, PyObject *args) {
- long pid;
+ pid_t pid;
long rss;
long vms;
long memtext;
@@ -203,7 +203,7 @@ psutil_proc_oneshot_info(PyObject *self, PyObject *args) {
PyObject *py_name;
PyObject *py_retlist;
- if (! PyArg_ParseTuple(args, "l", &pid))
+ if (! PyArg_ParseTuple(args, "O&", Py_PidConverter, &pid))
return NULL;
if (psutil_kinfo_proc(pid, &kp) == -1)
return NULL;
@@ -356,11 +356,11 @@ psutil_proc_oneshot_info(PyObject *self, PyObject *args) {
*/
static PyObject *
psutil_proc_name(PyObject *self, PyObject *args) {
- long pid;
+ pid_t pid;
kinfo_proc kp;
char str[1000];
- if (! PyArg_ParseTuple(args, "l", &pid))
+ if (! PyArg_ParseTuple(args, "O&", Py_PidConverter, &pid))
return NULL;
if (psutil_kinfo_proc(pid, &kp) == -1)
return NULL;
@@ -379,10 +379,10 @@ psutil_proc_name(PyObject *self, PyObject *args) {
*/
static PyObject *
psutil_proc_cmdline(PyObject *self, PyObject *args) {
- long pid;
+ pid_t pid;
PyObject *py_retlist = NULL;
- if (! PyArg_ParseTuple(args, "l", &pid))
+ if (! PyArg_ParseTuple(args, "O&", Py_PidConverter, &pid))
return NULL;
py_retlist = psutil_get_cmdline(pid);
if (py_retlist == NULL)
@@ -452,7 +452,7 @@ psutil_cpu_times(PyObject *self, PyObject *args) {
#if (defined(__FreeBSD_version) && __FreeBSD_version >= 800000) || PSUTIL_OPENBSD || defined(PSUTIL_NETBSD)
static PyObject *
psutil_proc_open_files(PyObject *self, PyObject *args) {
- long pid;
+ pid_t pid;
int i;
int cnt;
int regular;
@@ -467,7 +467,7 @@ psutil_proc_open_files(PyObject *self, PyObject *args) {
if (py_retlist == NULL)
return NULL;
- if (! PyArg_ParseTuple(args, "l", &pid))
+ if (! PyArg_ParseTuple(args, "O&", Py_PidConverter, &pid))
goto error;
if (psutil_kinfo_proc(pid, &kipp) == -1)
goto error;
diff --git a/psutil/arch/freebsd/proc_socks.c b/psutil/arch/freebsd/proc_socks.c
index a458a01e..90895ea4 100644
--- a/psutil/arch/freebsd/proc_socks.c
+++ b/psutil/arch/freebsd/proc_socks.c
@@ -179,7 +179,7 @@ psutil_search_tcplist(char *buf, struct kinfo_file *kif) {
PyObject *
psutil_proc_connections(PyObject *self, PyObject *args) {
// Return connections opened by process.
- long pid;
+ pid_t pid;
int i;
int cnt;
struct kinfo_file *freep = NULL;
diff --git a/psutil/arch/freebsd/specific.c b/psutil/arch/freebsd/specific.c
index 90ea81e8..b32d4f19 100644
--- a/psutil/arch/freebsd/specific.c
+++ b/psutil/arch/freebsd/specific.c
@@ -44,7 +44,7 @@
int
-psutil_kinfo_proc(const pid_t pid, struct kinfo_proc *proc) {
+psutil_kinfo_proc(pid_t pid, struct kinfo_proc *proc) {
// Fills a kinfo_proc struct based on process pid.
int mib[4];
size_t size;
@@ -180,7 +180,7 @@ psutil_get_proc_list(struct kinfo_proc **procList, size_t *procCount) {
* 1 for insufficient privileges.
*/
static char
-*psutil_get_cmd_args(long pid, size_t *argsize) {
+*psutil_get_cmd_args(pid_t pid, size_t *argsize) {
int mib[4];
int argmax;
size_t size = sizeof(argmax);
@@ -222,7 +222,7 @@ static char
// returns the command line as a python list object
PyObject *
-psutil_get_cmdline(long pid) {
+psutil_get_cmdline(pid_t pid) {
char *argstr = NULL;
size_t pos = 0;
size_t argsize = 0;
@@ -269,7 +269,7 @@ error:
*/
PyObject *
psutil_proc_exe(PyObject *self, PyObject *args) {
- long pid;
+ pid_t pid;
char pathname[PATH_MAX];
int error;
int mib[4];
@@ -313,7 +313,7 @@ psutil_proc_exe(PyObject *self, PyObject *args) {
PyObject *
psutil_proc_num_threads(PyObject *self, PyObject *args) {
// Return number of threads used by process as a Python integer.
- long pid;
+ pid_t pid;
struct kinfo_proc kp;
if (! PyArg_ParseTuple(args, "l", &pid))
return NULL;
@@ -330,7 +330,7 @@ psutil_proc_threads(PyObject *self, PyObject *args) {
// Thanks to Robert N. M. Watson:
// http://code.metager.de/source/xref/freebsd/usr.bin/procstat/
// procstat_threads.c
- long pid;
+ pid_t pid;
int mib[4];
struct kinfo_proc *kip = NULL;
struct kinfo_proc *kipp = NULL;
@@ -559,7 +559,7 @@ psutil_swap_mem(PyObject *self, PyObject *args) {
#if defined(__FreeBSD_version) && __FreeBSD_version >= 800000
PyObject *
psutil_proc_cwd(PyObject *self, PyObject *args) {
- long pid;
+ pid_t pid;
struct kinfo_file *freep = NULL;
struct kinfo_file *kif;
struct kinfo_proc kipp;
@@ -610,7 +610,7 @@ error:
#if defined(__FreeBSD_version) && __FreeBSD_version >= 800000
PyObject *
psutil_proc_num_fds(PyObject *self, PyObject *args) {
- long pid;
+ pid_t pid;
int cnt;
struct kinfo_file *freep;
@@ -769,7 +769,7 @@ PyObject *
psutil_proc_memory_maps(PyObject *self, PyObject *args) {
// Return a list of tuples for every process memory maps.
//'procstat' cmdline utility has been used as an example.
- long pid;
+ pid_t pid;
int ptrwidth;
int i, cnt;
char addr[1000];
@@ -885,7 +885,7 @@ psutil_proc_cpu_affinity_get(PyObject* self, PyObject* args) {
// Get process CPU affinity.
// Reference:
// http://sources.freebsd.org/RELENG_9/src/usr.bin/cpuset/cpuset.c
- long pid;
+ pid_t pid;
int ret;
int i;
cpuset_t mask;
@@ -927,7 +927,7 @@ psutil_proc_cpu_affinity_set(PyObject *self, PyObject *args) {
// Set process CPU affinity.
// Reference:
// http://sources.freebsd.org/RELENG_9/src/usr.bin/cpuset/cpuset.c
- long pid;
+ pid_t pid;
int i;
int seq_len;
int ret;