summaryrefslogtreecommitdiff
path: root/usr.bin/find
diff options
context:
space:
mode:
authorThorsten Lockert <tholo@cvs.openbsd.org>1996-10-24 03:46:06 +0000
committerThorsten Lockert <tholo@cvs.openbsd.org>1996-10-24 03:46:06 +0000
commit6344795100ad92aae94694aeace1e65374d288c1 (patch)
tree4c1a5d3f5195d202d8f212afa71f288ce43ad74f /usr.bin/find
parentbf3c020c3dffc6b56743d8a908fab5929d89c782 (diff)
Respond to SIGINFO; from PR #42
Diffstat (limited to 'usr.bin/find')
-rw-r--r--usr.bin/find/extern.h3
-rw-r--r--usr.bin/find/find.c8
-rw-r--r--usr.bin/find/main.c8
-rw-r--r--usr.bin/find/misc.c21
4 files changed, 32 insertions, 8 deletions
diff --git a/usr.bin/find/extern.h b/usr.bin/find/extern.h
index 9c1d2576b32..dcaa1e93ef0 100644
--- a/usr.bin/find/extern.h
+++ b/usr.bin/find/extern.h
@@ -1,4 +1,4 @@
-/* * $OpenBSD: extern.h,v 1.5 1996/09/01 04:56:25 tholo Exp $*/
+/* * $OpenBSD: extern.h,v 1.6 1996/10/24 03:46:03 tholo Exp $*/
/*-
* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
@@ -48,6 +48,7 @@ PLAN *paren_squish __P((PLAN *));
struct stat;
void printlong __P((char *, char *, struct stat *));
int queryuser __P((char **));
+void show_path __P((int));
PLAN *c_atime __P((char *));
PLAN *c_ctime __P((char *));
diff --git a/usr.bin/find/find.c b/usr.bin/find/find.c
index f14b03cd875..3f79284515d 100644
--- a/usr.bin/find/find.c
+++ b/usr.bin/find/find.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: find.c,v 1.2 1996/06/26 05:33:09 deraadt Exp $ */
+/* $OpenBSD: find.c,v 1.3 1996/10/24 03:46:04 tholo Exp $ */
/*-
* Copyright (c) 1991, 1993
@@ -38,7 +38,7 @@
#ifndef lint
/*static char sccsid[] = "from: @(#)find.c 8.1 (Berkeley) 6/6/93";*/
-static char rcsid[] = "$OpenBSD: find.c,v 1.2 1996/06/26 05:33:09 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: find.c,v 1.3 1996/10/24 03:46:04 tholo Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -149,12 +149,14 @@ FTS *tree; /* pointer to top of FTS hierarchy */
* take a search plan and an array of search paths and executes the plan
* over all FTSENT's returned for the given search paths.
*/
+
+FTSENT *entry; /* shared with SIGINFO handler */
+
void
find_execute(plan, paths)
PLAN *plan; /* search plan */
char **paths; /* array of pathnames to traverse */
{
- register FTSENT *entry;
PLAN *p;
if (!(tree = fts_open(paths, ftsoptions, (int (*)())NULL)))
diff --git a/usr.bin/find/main.c b/usr.bin/find/main.c
index 19fa3afe157..c193f1ee9e2 100644
--- a/usr.bin/find/main.c
+++ b/usr.bin/find/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.2 1996/06/26 05:33:11 deraadt Exp $ */
+/* $OpenBSD: main.c,v 1.3 1996/10/24 03:46:04 tholo Exp $ */
/*-
* Copyright (c) 1990, 1993
@@ -35,7 +35,7 @@
#ifndef lint
/*static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/6/93";*/
-static char rcsid[] = "$OpenBSD: main.c,v 1.2 1996/06/26 05:33:11 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: main.c,v 1.3 1996/10/24 03:46:04 tholo Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -45,6 +45,7 @@ static char rcsid[] = "$OpenBSD: main.c,v 1.2 1996/06/26 05:33:11 deraadt Exp $"
#include <errno.h>
#include <fcntl.h>
#include <fts.h>
+#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
@@ -66,11 +67,14 @@ main(argc, argv)
int argc;
char *argv[];
{
+ struct sigaction sa = { show_path, SA_RESTART, NULL };
register char **p, **start;
int ch;
(void)time(&now); /* initialize the time-of-day */
+ sigaction(SIGINFO, &sa, NULL);
+
p = start = argv;
ftsoptions = FTS_NOSTAT|FTS_PHYSICAL;
while ((ch = getopt(argc, argv, "Hdf:hXx")) != EOF)
diff --git a/usr.bin/find/misc.c b/usr.bin/find/misc.c
index edfbff64fc5..d43be538341 100644
--- a/usr.bin/find/misc.c
+++ b/usr.bin/find/misc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: misc.c,v 1.2 1996/06/26 05:33:12 deraadt Exp $ */
+/* $OpenBSD: misc.c,v 1.3 1996/10/24 03:46:05 tholo Exp $ */
/*-
* Copyright (c) 1990, 1993
@@ -38,7 +38,7 @@
#ifndef lint
/*static char sccsid[] = "from: @(#)misc.c 8.1 (Berkeley) 6/6/93";*/
-static char rcsid[] = "$OpenBSD: misc.c,v 1.2 1996/06/26 05:33:12 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: misc.c,v 1.3 1996/10/24 03:46:05 tholo Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -50,6 +50,7 @@ static char rcsid[] = "$OpenBSD: misc.c,v 1.2 1996/06/26 05:33:12 deraadt Exp $"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#include "find.h"
@@ -128,3 +129,19 @@ emalloc(len)
return (p);
err(1, NULL);
}
+
+/*
+ * show_path --
+ * called on SIGINFO
+ */
+/* ARGSUSED */
+void
+show_path(sig)
+ int sig;
+{
+ extern FTSENT *entry;
+
+ write(STDERR_FILENO, "find path: ", 11);
+ write(STDERR_FILENO, entry->fts_path, entry->fts_pathlen);
+ write(STDERR_FILENO, "\n", 1);
+}