#include #include #include #include #include int main() { struct pollfd info; info.fd = open("/proc/sys/kernel/hostname", O_RDONLY); info.events = 0; info.revents = 0; while (true) { int res = poll(&info, 1, -1); if (res > 0) { if (info.revents != 0) { char buffer[64]; gethostname(buffer, sizeof(buffer)); printf("Hostname has changed to: %s\n", buffer); } } } }