mirror of
https://git.FreeBSD.org/src.git
synced 2024-11-24 07:40:52 +00:00
find: add SIGINFO handler
Print number of files processed and path currently being processed on SIGINFO. Reviewed by: des, asomers Sponsored by: Axcient MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D43380
This commit is contained in:
parent
0e1d8481f9
commit
d06a00963b
@ -121,3 +121,4 @@ extern int exitstatus;
|
||||
extern time_t now;
|
||||
extern int dotfd;
|
||||
extern FTS *tree;
|
||||
extern volatile sig_atomic_t showinfo;
|
||||
|
@ -167,6 +167,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));
|
||||
@ -208,6 +209,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);
|
||||
|
@ -59,8 +59,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[])
|
||||
@ -72,6 +74,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;
|
||||
@ -152,3 +156,9 @@ usage(void)
|
||||
" find [-H | -L | -P] [-EXdsx] -f path [path ...] [expression]");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static void
|
||||
siginfo_handler(int sig __unused)
|
||||
{
|
||||
showinfo = 1;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user