summaryrefslogtreecommitdiff
path: root/psutil/_psutil_linux.c
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2019-02-24 09:55:52 -0800
committerGitHub <noreply@github.com>2019-02-24 09:55:52 -0800
commit7a2572268168e96c8841ca83ab1a89735ec02c3a (patch)
tree656a58683c5c48308152b302f1a31c4c82e74106 /psutil/_psutil_linux.c
parent88beee9e0d169e979a3027bf9e61c59ccc1ad6e3 (diff)
downloadpsutil-7a2572268168e96c8841ca83ab1a89735ec02c3a.tar.gz
#1428 in case of error, show the C syscall which caused it
Diffstat (limited to 'psutil/_psutil_linux.c')
-rw-r--r--psutil/_psutil_linux.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/psutil/_psutil_linux.c b/psutil/_psutil_linux.c
index 5b7a56ad..be808633 100644
--- a/psutil/_psutil_linux.c
+++ b/psutil/_psutil_linux.c
@@ -535,7 +535,7 @@ psutil_net_if_duplex_speed(PyObject* self, PyObject* args) {
sock = socket(AF_INET, SOCK_DGRAM, 0);
if (sock == -1)
- goto error;
+ return PyErr_SetFromOSErrnoWithSyscall("socket()");
strncpy(ifr.ifr_name, nic_name, sizeof(ifr.ifr_name));
// duplex and speed
@@ -558,20 +558,21 @@ psutil_net_if_duplex_speed(PyObject* self, PyObject* args) {
speed = 0;
}
else {
+ PyErr_SetFromOSErrnoWithSyscall("ioctl(SIOCETHTOOL)");
goto error;
}
}
- close(sock);
py_retlist = Py_BuildValue("[ii]", duplex, speed);
if (!py_retlist)
goto error;
+ close(sock);
return py_retlist;
error:
if (sock != -1)
close(sock);
- return PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
}