From nobody Tue Aug 01 14:30:53 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4RFcwr6Mfxz4qDlq; Tue, 1 Aug 2023 14:30:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4RFcwY3FCjz44s8; Tue, 1 Aug 2023 14:30:53 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1690900253; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=MU0nFMWaKHukNuVbKY6LyRy6/J8+1ClURHKq5sBI/9Q=; b=BKQjnjds6RIruH8cEI6cw4TdE+b7EI2zzdXc8YtxBqvcqWMUs5kBHpnEA6e0SSxJ76DH9D bZq/nP4h+7CYwyC0JENGm/bmYCFc/F3gSaXr+UY+eGX4PF7cWY7+BddM+Y2ygxwv8ug0Dz EpFgXr08DbZ9F8gdR1dbZIwHpivGO+tDDyKgp7x1TMAhpu5tsjn/Sfe+y20D3bR+xs8f/C chjCOIPoAAeXuNiVKmBVZoTbob354/d+/i2PvuScIJQzhICm6izqUZHtyaA2LGe6nuW/Cj ia77ceFkyp7mShsO8qvLcqdw8FCZdpUF9TqmWAd6geDWmEMx6hePDVo2Ah1Ktg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1690900253; a=rsa-sha256; cv=none; b=ybimhK6pM3USr/Ipd2jYgoprkhw6cYvnohn1W1PhUhcKdtYP4eU+1tRyN3TZKHkhMzucG4 r04uqxkjGxAofM/c0y3Qt2/TEQLJHtSlGj7vEhagftYxqSRn8A5WNZx4TCFVrC99NBZau4 2IaQgEc5hEqek2E3mY55+Io5ybVlZFNdwor0bcVz2QfJbBIUSpYR2LdUd3+F7MOqPYnUYE /Wm8dOHXkRdZvGjC+O/9nYtZxoEtJ2gpZK6oqiYZTaUoEmwAMj54BEiMSiI1mwR39eyh2v ZBiYOJx+26Qgve6cF8sqAQCaHe27ZQ9d63PLcMrfZKm9aE5pnkfHJp/kVrjOew== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1690900253; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=MU0nFMWaKHukNuVbKY6LyRy6/J8+1ClURHKq5sBI/9Q=; b=cMdKjstHXNZNJysnO5IBR3X4lbWm+DokaX+WBNMwinUeiheGTJN6ZSZuOZefrdY96D9Am6 kTjbe/PlhYUmZDVcFPPEw8UrPW6/B1xaMsK6LzEm8ut35CGniA9L029HX+ve5K0wyY5Vl+ t+FE2PclO31yuUaxpCfa+CHdI1BgBsewGaH/mOQ0sFnB3N2ymZl7tdJjhPS4FNUJT0LiQ5 98Wws+Q4rETVBlAcOGNNfClhBbu15VTbf3PFOIX3GRHCOddHlzpLMntqLwiX5ns2Qi+q5o 8lX2jUmxc5YDF0JwkrNXHn2xlgBDPIddicqlDZTSi+0Om93GAltlpWFzsVpXZA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4RFcwY1YWWzh2Q; Tue, 1 Aug 2023 14:30:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 371EUrfk058637; Tue, 1 Aug 2023 14:30:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 371EUr54058636; Tue, 1 Aug 2023 14:30:53 GMT (envelope-from git) Date: Tue, 1 Aug 2023 14:30:53 GMT Message-Id: <202308011430.371EUr54058636@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mitchell Horne Subject: git: 258c6d5e9b98 - main - filemon(4): Better error checking in code example List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 258c6d5e9b98122e45c23122cccafee6ce2958b9 Auto-Submitted: auto-generated The branch main has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=258c6d5e9b98122e45c23122cccafee6ce2958b9 commit 258c6d5e9b98122e45c23122cccafee6ce2958b9 Author: Pau Amma AuthorDate: 2023-08-01 14:24:44 +0000 Commit: Mitchell Horne CommitDate: 2023-08-01 14:30:38 +0000 filemon(4): Better error checking in code example Discussed with: dim Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D38367 --- share/man/man4/filemon.4 | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/share/man/man4/filemon.4 b/share/man/man4/filemon.4 index 9fb2fe10a2ec..b7e7f30133be 100644 --- a/share/man/man4/filemon.4 +++ b/share/man/man4/filemon.4 @@ -31,7 +31,7 @@ .\" .\" $FreeBSD$ .\" -.Dd February 1, 2022 +.Dd August 1, 2023 .Dt FILEMON 4 .Os .Sh NAME @@ -193,12 +193,13 @@ no log entry for the system call. #include #include #include +#include #include static void open_filemon(void) { - pid_t child; + pid_t child, wait_rv; int fm_fd, fm_log; if ((fm_fd = open("/dev/filemon", O_RDWR | O_CLOEXEC)) == -1) @@ -215,8 +216,14 @@ open_filemon(void) if (ioctl(fm_fd, FILEMON_SET_PID, &child) == -1) err(1, "Cannot set filemon PID"); /* Do something here. */ - } else { - wait(&child); + } else if (child == -1) + err(1, "Cannot fork child"); + else { + while ((wait_rv = wait(&child)) == -1 && + errno == EINTR) + ; + if (wait_rv == -1) + err(1, "cannot wait for child"); close(fm_fd); } }