From owner-svn-src-all@FreeBSD.ORG Fri Jun 14 08:28:08 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id D05DE4EE; Fri, 14 Jun 2013 08:28:08 +0000 (UTC) (envelope-from pluknet@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id C1D701BC8; Fri, 14 Jun 2013 08:28:08 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r5E8S8Kt033145; Fri, 14 Jun 2013 08:28:08 GMT (envelope-from pluknet@svn.freebsd.org) Received: (from pluknet@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r5E8S8sC033144; Fri, 14 Jun 2013 08:28:08 GMT (envelope-from pluknet@svn.freebsd.org) Message-Id: <201306140828.r5E8S8sC033144@svn.freebsd.org> From: Sergey Kandaurov Date: Fri, 14 Jun 2013 08:28:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r251744 - head/share/man/man4 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Jun 2013 08:28:08 -0000 Author: pluknet Date: Fri Jun 14 08:28:08 2013 New Revision: 251744 URL: http://svnweb.freebsd.org/changeset/base/251744 Log: Fix and improve filemon(4) example: - remove return statements from void function [1] - include missing header - use O_CLOEXEC instead of separate fcntl() calls PR: docs/179459 [1] MFC after: 1 week Modified: head/share/man/man4/filemon.4 Modified: head/share/man/man4/filemon.4 ============================================================================== --- head/share/man/man4/filemon.4 Fri Jun 14 08:26:58 2013 (r251743) +++ head/share/man/man4/filemon.4 Fri Jun 14 08:28:08 2013 (r251744) @@ -31,7 +31,7 @@ .\" .\" $FreeBSD$ .\" -.Dd May 30, 2012 +.Dd June 14, 2013 .Dt FILEMON 4 .Os .Sh NAME @@ -126,6 +126,7 @@ is set to indicate the error. #include #include #include +#include static void open_filemon(void) @@ -133,29 +134,24 @@ open_filemon(void) pid_t child; int fm_fd, fm_log; - if ((fm_fd = open("/dev/filemon", O_RDWR)) == -1) + if ((fm_fd = open("/dev/filemon", O_RDWR | O_CLOEXEC)) == -1) err(1, "open(\e"/dev/filemon\e", O_RDWR)"); if ((fm_log = open("filemon.out", - O_CREAT | O_WRONLY | O_TRUNC, DEFFILEMODE)) == -1) + O_CREAT | O_WRONLY | O_TRUNC | O_CLOEXEC, DEFFILEMODE)) == -1) err(1, "open(filemon.out)"); if (ioctl(fm_fd, FILEMON_SET_FD, &fm_log) == -1) err(1, "Cannot set filemon log file descriptor"); - /* Set up these two fd's to close on exec. */ - (void)fcntl(fm_fd, F_SETFD, FD_CLOEXEC); - (void)fcntl(fm_log, F_SETFD, FD_CLOEXEC); if ((child = fork()) == 0) { child = getpid(); if (ioctl(fm_fd, FILEMON_SET_PID, &child) == -1) err(1, "Cannot set filemon PID"); /* Do something here. */ - return 0; } else { wait(&child); close(fm_fd); } - return 0; } .Ed .Pp