From nobody Thu Jun 13 18:12:52 2024 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 4W0VrP0vlcz5P5vQ; Thu, 13 Jun 2024 18:12: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 4W0VrP092gz4gnd; Thu, 13 Jun 2024 18:12:53 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1718302373; 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=CpPZrA4lXYsYcbaBzFGW3ybhd9b3cJqHJPNvO3B2ng4=; b=VpQVODy19Ax5znBuCL+sCEltCrGsZX3F1ogLDC6w1GLuLKOYZFz7seoPDf6VqVuA7iku7R QCuZHC9MU8/lsJOsEk8VqMVKjLn8czG78mPa82FjbCEEaRDwZNeOiQyNaQlFYgfImR7mjJ /honsZ2naJsKpmDZpw9YUP87IyBZIg3giGdI/WHdJS1AxcTOiUnelIlEAZJil5g8eBIqow h8m5MZi7hnJmEzZox7LbkmqlDwpL7+WaHuOp5UuGdNiG93ztcuHyFlIx1oXevjONzhSXZ1 d5Vc67Mi/eIEKmAe4a+4WU/bZaFTTcT9AM6Rbad5YBCjgP+svuC4/lH0kSbp2w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1718302373; a=rsa-sha256; cv=none; b=AuqIiOQ5vbieXGBNi2XhaM2OgU/uuY32Z9y29mV8Cwrkz7Is5mI/vQT+EnqsKu5hzhtLZ1 xV/yB7rBGMTmr1OIZfqm6YQdHgQKzsLGwCyXRIKfLwXbdr/hVvG+OVX1aqOGJ89iMqPDr3 zEL10Wh8mF/X3tE4MJU1GfKh1UOYfsITDA9O9m+baci2WpNb2co6Iyl1GVzNYIxx8d45o3 OG7p/6MI02hS8wSwasetW2qh4ZAouP0bfHS8Htjii/OX/p8T151s/myAYNA5PWc8zC+Q0Y 6P5wgoSTsyNKHLZ2OjxmFT0QMNZrWW47tX7RmwJrdxYCIC4ET8bBPGuJGqKN1g== 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=1718302373; 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=CpPZrA4lXYsYcbaBzFGW3ybhd9b3cJqHJPNvO3B2ng4=; b=aYdMqSuQeSpkuQETkRNpeQVU53GjvxzrYbr5VL8ZPlS/4SNhOtv8D66frdGAS68Sy7z2iA YJ215rSdFxiJcqpCmiUYZJX4dCQoKNV05U/DpgpNVB0tjXrbSHygPcUxHjFKs5ks+gsw1u 6qifMyMrxYz0m2zdTe5ATEYwnPhm52TfQZthcZazD/XjiQXHzEHzL5ZsWTbgevKx5kBE0L /Cwvxkmjg4oHp4oy3MsPL5iNtGDxguYD9vGQ12ZjHM0xc7NkHYQsNNduC19Bq8KRmivWg9 l5qtxKy73Je1ALeKXWiOECMJO76snOnK6w1OkibyKnm3X2wKdfW2KKW22qDLbQ== 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 4W0VrN6tCDznTm; Thu, 13 Jun 2024 18:12:52 +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 45DICqMT037352; Thu, 13 Jun 2024 18:12:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 45DICqoK037349; Thu, 13 Jun 2024 18:12:52 GMT (envelope-from git) Date: Thu, 13 Jun 2024 18:12:52 GMT Message-Id: <202406131812.45DICqoK037349@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alan Somers Subject: git: 927bb4aa5f81 - stable/14 - find: add SIGINFO handler 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: asomers X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 927bb4aa5f8128537145d69b13641afd68aa01d9 Auto-Submitted: auto-generated The branch stable/14 has been updated by asomers: URL: https://cgit.FreeBSD.org/src/commit/?id=927bb4aa5f8128537145d69b13641afd68aa01d9 commit 927bb4aa5f8128537145d69b13641afd68aa01d9 Author: Goran Mekić AuthorDate: 2024-01-11 22:35:25 +0000 Commit: Alan Somers CommitDate: 2024-06-13 18:11:32 +0000 find: add SIGINFO handler Print number of files processed and path currently being processed on SIGINFO. Reviewed by: des, asomers Sponsored by: Axcient Differential Revision: https://reviews.freebsd.org/D43380 (cherry picked from commit d06a00963b7f724b6fdd7d7cdcbed57c534196a9) --- usr.bin/find/extern.h | 1 + usr.bin/find/find.c | 9 +++++++++ usr.bin/find/main.c | 10 ++++++++++ 3 files changed, 20 insertions(+) diff --git a/usr.bin/find/extern.h b/usr.bin/find/extern.h index 3436f8cf07bf..323b9bfdfb93 100644 --- a/usr.bin/find/extern.h +++ b/usr.bin/find/extern.h @@ -126,3 +126,4 @@ extern int exitstatus; extern time_t now; extern int dotfd; extern FTS *tree; +extern volatile sig_atomic_t showinfo; diff --git a/usr.bin/find/find.c b/usr.bin/find/find.c index 3bff4982b4b6..57225e8fa23f 100644 --- a/usr.bin/find/find.c +++ b/usr.bin/find/find.c @@ -172,6 +172,7 @@ find_execute(PLAN *plan, char *paths[]) { FTSENT *entry; PLAN *p; + size_t counter = 0; int e; tree = fts_open(paths, ftsoptions, (issort ? find_compare : NULL)); @@ -213,6 +214,14 @@ find_execute(PLAN *plan, char *paths[]) continue; #endif /* FTS_W */ } + + if (showinfo) { + fprintf(stderr, "Scanning: %s/%s\n", entry->fts_path, entry->fts_name); + fprintf(stderr, "Scanned: %lu\n\n", counter); + showinfo = 0; + } + ++counter; + #define BADCH " \t\n\\'\"" if (isxargs && strpbrk(entry->fts_path, BADCH)) { (void)fflush(stdout); diff --git a/usr.bin/find/main.c b/usr.bin/find/main.c index 56f1feece6e4..9e02e75638f4 100644 --- a/usr.bin/find/main.c +++ b/usr.bin/find/main.c @@ -68,8 +68,10 @@ int isxargs; /* don't permit xargs delimiting chars */ int mindepth = -1, maxdepth = -1; /* minimum and maximum depth */ int regexp_flags = REG_BASIC; /* use the "basic" regexp by default*/ int exitstatus; +volatile sig_atomic_t showinfo = 0; static void usage(void) __dead2; +static void siginfo_handler(int sig __unused); int main(int argc, char *argv[]) @@ -81,6 +83,8 @@ main(int argc, char *argv[]) (void)time(&now); /* initialize the time-of-day */ + (void)signal(SIGINFO, siginfo_handler); + p = start = argv; Hflag = Lflag = 0; ftsoptions = FTS_NOSTAT | FTS_PHYSICAL; @@ -161,3 +165,9 @@ usage(void) " find [-H | -L | -P] [-EXdsx] -f path [path ...] [expression]"); exit(1); } + +static void +siginfo_handler(int sig __unused) +{ + showinfo = 1; +}