Add timeout to socket

This commit is contained in:
alesapin 2018-08-21 18:24:20 +03:00
parent b657c6b848
commit 726428a2c5

View File

@ -139,7 +139,13 @@ void TaskStatsInfoGetter::init()
if (netlink_socket_fd >= 0)
return;
struct timeval tv;
tv.tv_sec = 5;
tv.tv_usec = 0;
netlink_socket_fd = ::socket(PF_NETLINK, SOCK_RAW, NETLINK_GENERIC);
::setsockopt(netlink_socket_fd, SOL_SOCKET, SO_RCVTIMEO, reinterpret_cast<const char *>(&tv), sizeof(tv));
if (netlink_socket_fd < 0)
throwFromErrno("Can't create PF_NETLINK socket");