summaryrefslogtreecommitdiff
path: root/psutil
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2020-01-27 00:34:09 +0000
committerGiampaolo Rodola <g.rodola@gmail.com>2020-01-27 00:34:09 +0000
commit126f03a6347d45a83b14570f9dbede4f0341e7a5 (patch)
tree379964f9a5bacbc5998f4a5949217eeb93c0b117 /psutil
parent90e33a81f75f861774f775547121ab9f14cfd6d5 (diff)
downloadpsutil-126f03a6347d45a83b14570f9dbede4f0341e7a5.tar.gz
port openbsd
Diffstat (limited to 'psutil')
-rw-r--r--psutil/arch/openbsd/specific.c27
-rw-r--r--psutil/arch/openbsd/specific.h6
2 files changed, 17 insertions, 16 deletions
diff --git a/psutil/arch/openbsd/specific.c b/psutil/arch/openbsd/specific.c
index 18079b89..d97a8f9b 100644
--- a/psutil/arch/openbsd/specific.c
+++ b/psutil/arch/openbsd/specific.c
@@ -90,7 +90,7 @@ psutil_kinfo_proc(pid_t pid, struct kinfo_proc *proc) {
struct kinfo_file *
-kinfo_getfile(long pid, int* cnt) {
+kinfo_getfile(pid_t pid, int* cnt) {
// Mimic's FreeBSD kinfo_file call, taking a pid and a ptr to an
// int as arg and returns an array with cnt struct kinfo_file.
int mib[6];
@@ -99,7 +99,7 @@ kinfo_getfile(long pid, int* cnt) {
mib[0] = CTL_KERN;
mib[1] = KERN_FILE;
mib[2] = KERN_FILE_BYPID;
- mib[3] = (int) pid;
+ mib[3] = pid;
mib[4] = sizeof(struct kinfo_file);
mib[5] = 0;
@@ -179,7 +179,7 @@ psutil_get_proc_list(struct kinfo_proc **procList, size_t *procCount) {
static char **
-_psutil_get_argv(long pid) {
+_psutil_get_argv(pid_t pid) {
static char **argv;
int argv_mib[] = {CTL_KERN, KERN_PROC_ARGS, pid, KERN_PROC_ARGV};
size_t argv_size = 128;
@@ -204,7 +204,7 @@ _psutil_get_argv(long pid) {
// returns the command line as a python list object
PyObject *
-psutil_get_cmdline(long pid) {
+psutil_get_cmdline(pid_t pid) {
static char **argv;
char **p;
PyObject *py_arg = NULL;
@@ -241,7 +241,7 @@ psutil_proc_threads(PyObject *self, PyObject *args) {
// https://github.com/janmojzis/pstree/blob/master/proc_kvm.c
// Note: this requires root access, else it will fail trying
// to access /dev/kmem.
- long pid;
+ pid_t pid;
kvm_t *kd = NULL;
int nentries, i;
char errbuf[4096];
@@ -251,7 +251,7 @@ psutil_proc_threads(PyObject *self, PyObject *args) {
if (py_retlist == NULL)
return NULL;
- if (! PyArg_ParseTuple(args, "l", &pid))
+ if (! PyArg_ParseTuple(args, _Py_PARSE_PID, &pid))
goto error;
kd = kvm_openfiles(0, 0, 0, O_RDONLY, errbuf);
@@ -276,7 +276,7 @@ psutil_proc_threads(PyObject *self, PyObject *args) {
continue;
if (kp[i].p_pid == pid) {
py_tuple = Py_BuildValue(
- "Idd",
+ _Py_PARSE_PID "dd",
kp[i].p_tid,
PSUTIL_KPT2DOUBLE(kp[i].p_uutime),
PSUTIL_KPT2DOUBLE(kp[i].p_ustime));
@@ -402,13 +402,13 @@ error:
PyObject *
psutil_proc_num_fds(PyObject *self, PyObject *args) {
- long pid;
+ pid_t pid;
int cnt;
struct kinfo_file *freep;
struct kinfo_proc kipp;
- if (! PyArg_ParseTuple(args, "l", &pid))
+ if (! PyArg_ParseTuple(args, _Py_PARSE_PID, &pid))
return NULL;
if (psutil_kinfo_proc(pid, &kipp) == -1)
@@ -428,12 +428,12 @@ psutil_proc_cwd(PyObject *self, PyObject *args) {
// Reference:
// https://github.com/openbsd/src/blob/
// 588f7f8c69786211f2d16865c552afb91b1c7cba/bin/ps/print.c#L191
- long pid;
+ pid_t pid;
struct kinfo_proc kp;
char path[MAXPATHLEN];
size_t pathlen = sizeof path;
- if (! PyArg_ParseTuple(args, "l", &pid))
+ if (! PyArg_ParseTuple(args, _Py_PARSE_PID, &pid))
return NULL;
if (psutil_kinfo_proc(pid, &kp) == -1)
return NULL;
@@ -492,7 +492,7 @@ psutil_inet6_addrstr(struct in6_addr *p)
*/
PyObject *
psutil_proc_connections(PyObject *self, PyObject *args) {
- long pid;
+ pid_t pid;
int i;
int cnt;
struct kinfo_file *freep = NULL;
@@ -509,7 +509,8 @@ psutil_proc_connections(PyObject *self, PyObject *args) {
if (py_retlist == NULL)
return NULL;
- if (! PyArg_ParseTuple(args, "lOO", &pid, &py_af_filter, &py_type_filter))
+ if (! PyArg_ParseTuple(args, _Py_PARSE_PID "OO", &pid, &py_af_filter,
+ &py_type_filter))
goto error;
if (!PySequence_Check(py_af_filter) || !PySequence_Check(py_type_filter)) {
PyErr_SetString(PyExc_TypeError, "arg 2 or 3 is not a sequence");
diff --git a/psutil/arch/openbsd/specific.h b/psutil/arch/openbsd/specific.h
index 4f870268..b8170a02 100644
--- a/psutil/arch/openbsd/specific.h
+++ b/psutil/arch/openbsd/specific.h
@@ -10,10 +10,10 @@
typedef struct kinfo_proc kinfo_proc;
int psutil_kinfo_proc(pid_t pid, struct kinfo_proc *proc);
-struct kinfo_file * kinfo_getfile(long pid, int* cnt);
+struct kinfo_file * kinfo_getfile(pid_t pid, int* cnt);
int psutil_get_proc_list(struct kinfo_proc **procList, size_t *procCount);
-char **_psutil_get_argv(long pid);
-PyObject * psutil_get_cmdline(long pid);
+char **_psutil_get_argv(pid_t pid);
+PyObject * psutil_get_cmdline(pid_t pid);
//
PyObject *psutil_proc_threads(PyObject *self, PyObject *args);