This how I think ifplugd should work, it should not poll it should just use libnetlink and read for the next message.
The RUNNING flag works for wireless and non-wireless devices. If there is a driver it doesn't work on than that is a bug in the device driver and should be fixed ASAP, not worked around in user space. =============================== /* Demo of how to monitor link status with netlink */ #include <stdio.h> #include <sys/types.h> #include <sys/socket.h> #include <sys/ioctl.h> #include <linux/netdevice.h> #include "libnetlink.h" static int filter_link(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg) { struct ifinfomsg *ifi = NLMSG_DATA(n); struct rtattr * tb[IFLA_MAX+1]; int len = n->nlmsg_len; if (n->nlmsg_type != RTM_NEWLINK && n->nlmsg_type != RTM_DELLINK) return 0; len -= NLMSG_LENGTH(sizeof(*ifi)); if (len < 0) return -1; parse_rtattr(tb, IFLA_MAX, IFLA_RTA(ifi), len); if (n->nlmsg_type == RTM_DELLINK) printf("Deleted "); printf("%d: %s %s,%sCARRIER\n", ifi->ifi_index, tb[IFLA_IFNAME] ? (char *) RTA_DATA(tb[IFLA_IFNAME]) : "???", (ifi->ifi_flags & IFF_UP) ? "UP" : "DOWN", (ifi->ifi_flags & IFF_RUNNING) ? "": "NO"); return 0; } int main(int argc, char **argv) { struct rtnl_handle rth; if (rtnl_open(&rth, RTMGRP_LINK) < 0) { fprintf(stderr, "Cannot open rtnetlink\n"); return -1; } if (rtnl_wilddump_request(&rth, AF_UNSPEC, RTM_NEWLINK) < 0) { perror("Cannot send dump request"); return -1; } return (rtnl_listen(&rth, filter_link, NULL) < 0) ? 1 : 0; } - To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html