我知道我可以通过SIOCETHTOOL / ETHTOOL_GLINK ioctl轮询链接状态,但这需要无休止地请求状态.解析/ var / log / messages也是如此.所以我的任务是,在Linux下有什么方法可以等待用户空间的以太网电缆的状态更改?
解决方法:
ifplugd
怎么样?
ifplugd
is a Linux daemon which will automatically configure your ethernet device when a cable is plugged in and automatically unconfigure it if the cable is pulled. This is useful on laptops with onboard network adapters, since it will only configure the interface when a cable is really connected.
(还有netplugd,但它是discontinued.)