Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 5 Jul 2017 15:04:45 +0200
From:      "Tobias C. Berner" <tcberner@freebsd.org>
To:        freebsd-hackers@freebsd.org
Subject:   How to use kevent to monitor removal of a socket-file
Message-ID:  <CAOshKte7jK1qEr0Cu4=zFbsL6U0QeA9y=-%2BjZ-O5bL_T%2BmFiFQ@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
Hi there


I want to be notified once a given socket file, say '/var/run/socket.pipe'
gets deleted.


Something like

+---------------------------------------------+
|   string path = "/var/run/socket.pipe";     |
|   int fd = open(path, O_RDONLY);            |
|   EV_SET(&k, fd, ...);                      |
|   kevent(..., &k, ...);                     |
+---------------------------------------------+

however does not work, as open(2) does not handle socket files, throwing
back
    ENOTSUPP : An attempt was made to open a socket (not currently
implemented).


What is the proper way to monitor such files?
* Just monitoring the parent directory for changes, and look up whether the
file still exists each time?
* Connecting to the socket and using EVFILT_READ and wait for EOF?


Am I missing the obvious solution here?



mfg Tobias



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAOshKte7jK1qEr0Cu4=zFbsL6U0QeA9y=-%2BjZ-O5bL_T%2BmFiFQ>