Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/find only setup siginfo handler if we have a tty.



details:   https://anonhg.NetBSD.org/src/rev/18dca52bf91b
branches:  trunk
changeset: 760144:18dca52bf91b
user:      christos <christos%NetBSD.org@localhost>
date:      Tue Dec 28 15:28:31 2010 +0000

description:
only setup siginfo handler if we have a tty.

diffstat:

 usr.bin/find/find.c |  11 +++++++++--
 usr.bin/find/main.c |  11 ++---------
 2 files changed, 11 insertions(+), 11 deletions(-)

diffs (83 lines):

diff -r d527e14cf172 -r 18dca52bf91b usr.bin/find/find.c
--- a/usr.bin/find/find.c       Tue Dec 28 14:45:30 2010 +0000
+++ b/usr.bin/find/find.c       Tue Dec 28 15:28:31 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: find.c,v 1.26 2010/12/27 16:09:46 christos Exp $       */
+/*     $NetBSD: find.c,v 1.27 2010/12/28 15:28:31 christos Exp $       */
 
 /*-
  * Copyright (c) 1991, 1993, 1994
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "from: @(#)find.c       8.5 (Berkeley) 8/5/94";
 #else
-__RCSID("$NetBSD: find.c,v 1.26 2010/12/27 16:09:46 christos Exp $");
+__RCSID("$NetBSD: find.c,v 1.27 2010/12/28 15:28:31 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -159,12 +159,19 @@
 static __inline void
 sig_init(void)
 {
+       struct sigaction sa;
        notty = !(isatty(STDIN_FILENO) || isatty(STDOUT_FILENO) ||
            isatty(STDERR_FILENO));
        if (notty)
                return;
        sigemptyset(&ss);
        sigaddset(&ss, SIGINFO); /* block SIGINFO */
+
+       memset(&sa, 0, sizeof(sa));
+       sa.sa_flags = SA_RESTART;
+       sa.sa_handler = show_path;
+       (void)sigaction(SIGINFO, &sa, NULL);
+
 }
 
 static __inline void
diff -r d527e14cf172 -r 18dca52bf91b usr.bin/find/main.c
--- a/usr.bin/find/main.c       Tue Dec 28 14:45:30 2010 +0000
+++ b/usr.bin/find/main.c       Tue Dec 28 15:28:31 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.28 2008/07/21 14:19:22 lukem Exp $  */
+/*     $NetBSD: main.c,v 1.29 2010/12/28 15:28:31 christos Exp $       */
 
 /*-
  * Copyright (c) 1990, 1993, 1994
@@ -39,7 +39,7 @@
 #else
 __COPYRIGHT("@(#) Copyright (c) 1990, 1993, 1994\
  The Regents of the University of California.  All rights reserved.");
-__RCSID("$NetBSD: main.c,v 1.28 2008/07/21 14:19:22 lukem Exp $");
+__RCSID("$NetBSD: main.c,v 1.29 2010/12/28 15:28:31 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -50,7 +50,6 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <fts.h>
-#include <signal.h>
 #include <locale.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -76,18 +75,12 @@
 int
 main(int argc, char *argv[])
 {
-       struct sigaction sa;
        char **p, **start;
        int ch;
 
        (void)time(&now);       /* initialize the time-of-day */
        (void)setlocale(LC_ALL, "");
 
-       memset(&sa, 0, sizeof(sa));
-       sa.sa_flags = SA_RESTART;
-       sa.sa_handler = show_path;
-       sigaction(SIGINFO, &sa, NULL);
-
        /* array to hold dir list.  at most (argc - 1) elements. */
        p = start = malloc(argc * sizeof (char *));
        if (p == NULL)



Home | Main Index | Thread Index | Old Index