From owner-freebsd-hackers@freebsd.org Wed Jul 5 13:58:48 2017 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7F31ADABC05 for ; Wed, 5 Jul 2017 13:58:48 +0000 (UTC) (envelope-from tcberner@gmail.com) Received: from mail-yb0-f177.google.com (mail-yb0-f177.google.com [209.85.213.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 402D381836 for ; Wed, 5 Jul 2017 13:58:47 +0000 (UTC) (envelope-from tcberner@gmail.com) Received: by mail-yb0-f177.google.com with SMTP id f194so13043398yba.3 for ; Wed, 05 Jul 2017 06:58:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=ci2So/S40CKjp4UG7bSCoBOeSeSvdXZj+OZTNgokJEQ=; b=mBeMlUeeqiJRGARzpdtxrpGR72QzuyyZF45r8ybtrOFFy+mztAB8+UlMoXpViSqvOl wEdnob1W6ZV4ZndAVNKl46X6CUM6dy7ZhwKf68hUCXlfcoP7xKYfTSAGnSvS6rUWMA1W rUaIWs97WQ9IfSjkpa6SwsAQXnc8enwa7yeoSYWFIP86+jzgdPNO1fLlsxd0IzRHY6bp Zq1rL+nbzIbu8BXwxAtLW0dxHrfmDlH3tQuwPvuLFyFVeq7NndM/n1yXeAZqANPGZfbM s3cHSUNwec16PsH5k9tsKmHWGozRPvF6plzjWQL4KXus3RdQqIl2VZzn++b42TdVKn8U TNRg== X-Gm-Message-State: AIVw111ryFa3+2odRrbTINxqntAcLudTQaeNgbx1iUhCMKFMnluKlU+9 MEftTOMNFqkhmNlXJ9k= X-Received: by 10.37.41.65 with SMTP id p62mr15155782ybp.36.1499259885982; Wed, 05 Jul 2017 06:04:45 -0700 (PDT) Received: from mail-yb0-f178.google.com (mail-yb0-f178.google.com. [209.85.213.178]) by smtp.gmail.com with ESMTPSA id d139sm6215788ywe.40.2017.07.05.06.04.45 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Jul 2017 06:04:45 -0700 (PDT) Received: by mail-yb0-f178.google.com with SMTP id 84so71876082ybe.0 for ; Wed, 05 Jul 2017 06:04:45 -0700 (PDT) X-Received: by 10.37.164.66 with SMTP id f60mr9650894ybi.23.1499259885501; Wed, 05 Jul 2017 06:04:45 -0700 (PDT) MIME-Version: 1.0 Received: by 10.129.86.3 with HTTP; Wed, 5 Jul 2017 06:04:45 -0700 (PDT) From: "Tobias C. Berner" Date: Wed, 5 Jul 2017 15:04:45 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: How to use kevent to monitor removal of a socket-file To: freebsd-hackers@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Jul 2017 13:58:48 -0000 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