Module Name:    src
Committed By:   christos
Date:           Tue Jan 12 14:43:32 UTC 2010

Modified Files:
        src/usr.bin/mail: popen.c

Log Message:
- 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.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/usr.bin/mail/popen.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/mail/popen.c
diff -u src/usr.bin/mail/popen.c:1.25 src/usr.bin/mail/popen.c:1.26
--- src/usr.bin/mail/popen.c:1.25	Fri Apr 10 09:08:25 2009
+++ src/usr.bin/mail/popen.c	Tue Jan 12 09:43:31 2010
@@ -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*/
 }
 

Reply via email to