Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/mail - 1 -> EXIT_FAILURE



details:   https://anonhg.NetBSD.org/src/rev/07b3dd2e7e6d
branches:  trunk
changeset: 750725:07b3dd2e7e6d
user:      christos <christos%NetBSD.org@localhost>
date:      Tue Jan 12 14:43:31 2010 +0000

description:
- 1 -> EXIT_FAILURE
- preallocate child struct, since the signal handler can be called before
  wait_child, and we cannot allocate a child struct there. there is a signal
  race still here if the program exits and the signal handler is called before
  we allocate the struct.

diffstat:

 usr.bin/mail/popen.c |  10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diffs (52 lines):

diff -r 1727a8e7b2ab -r 07b3dd2e7e6d usr.bin/mail/popen.c
--- a/usr.bin/mail/popen.c      Tue Jan 12 12:21:04 2010 +0000
+++ b/usr.bin/mail/popen.c      Tue Jan 12 14:43:31 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: popen.c,v 1.25 2009/04/10 13:08:25 christos Exp $      */
+/*     $NetBSD: popen.c,v 1.26 2010/01/12 14:43:31 christos Exp $      */
 
 /*
  * Copyright (c) 1980, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)popen.c    8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: popen.c,v 1.25 2009/04/10 13:08:25 christos Exp $");
+__RCSID("$NetBSD: popen.c,v 1.26 2010/01/12 14:43:31 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -67,6 +67,7 @@
        struct child *link;
 };
 static struct child *child, *child_freelist = NULL;
+static struct child *findchild(pid_t, int);
 
 
 #if 0  /* XXX - debugging stuff.  This should go away eventually! */
@@ -104,7 +105,7 @@
                        (void)free(p);
                        return;
                }
-       errx(1, "Invalid file pointer");
+       errx(EXIT_FAILURE, "Invalid file pointer");
 }
 
 PUBLIC void
@@ -220,6 +221,7 @@
                warn("%s", argv[0]);
                _exit(1);
        }
+       (void)findchild(pid, 0);
        return pid;
 }
 
@@ -348,7 +350,7 @@
        for (p = fp_head; p; p = p->link)
                if (p->fp == fp)
                        return p->pid;
-       errx(1, "Invalid file pointer");
+       errx(EXIT_FAILURE, "Invalid file pointer");
        /*NOTREACHED*/
 }
 



Home | Main Index | Thread Index | Old Index