public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* Condition signal.h inclusion in sys/wait.h (bug 21560)
@ 2017-06-09  3:19 Joseph Myers
  2017-06-09 12:13 ` Zack Weinberg
  0 siblings, 1 reply; 2+ messages in thread
From: Joseph Myers @ 2017-06-09  3:19 UTC (permalink / raw)
  To: libc-alpha

sys/wait.h includes signal.h unconditionally.  But the permission to
do so is UX-shaded in XPG4.2, and XSI-shaded in POSIX before 2008, so
this should not be unconditional.  This patch fixes this
conservatively: the include is kept, but conditioned on the standards
that permit it (meaning it is still present by default, because
non-XSI POSIX.1:2008 is enabled by default).  <bits/types.h> is now
included unconditionally to provide the required definition of
__pid_t; it was previously included via <signal.h>.  Some standards
require pid_t to be defined here, and all allow it to be defined here;
previously defined via <signal.h>, it's now defined directly in this
header.

Tested for x86_64.  This does not fix any of the sys/wait.h
conformtest failures, but substantially reduces the number of
namespace failures for sys/wait.h for XPG4 and POSIX.

2017-06-09  Joseph Myers  <joseph@codesourcery.com>

	[BZ #21560]
	* posix/sys/wait.h: Condition include of <signal.h> on
	[__USE_XOPEN_EXTENDED || __USE_XOPEN2K8].  Include <bits/types.h>
	unconditionally.
	[!__pid_t_defined] (pid_t): Define typedef.

diff --git a/posix/sys/wait.h b/posix/sys/wait.h
index d5b7e4d..909979b 100644
--- a/posix/sys/wait.h
+++ b/posix/sys/wait.h
@@ -26,7 +26,15 @@
 
 __BEGIN_DECLS
 
-#include <signal.h>
+#include <bits/types.h>
+#ifndef __pid_t_defined
+typedef __pid_t pid_t;
+# define __pid_t_defined
+#endif
+
+#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
+# include <signal.h>
+#endif
 
 /* These macros could also be defined in <stdlib.h>.  */
 #if !defined _STDLIB_H || (!defined __USE_XOPEN && !defined __USE_XOPEN2K8)
@@ -98,7 +106,6 @@ extern __pid_t waitpid (__pid_t __pid, int *__stat_loc, int __options);
 
 #if defined __USE_XOPEN || defined __USE_XOPEN2K8
 # ifndef __id_t_defined
-#  include <bits/types.h>
 typedef __id_t id_t;
 #  define __id_t_defined
 # endif

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Condition signal.h inclusion in sys/wait.h (bug 21560)
  2017-06-09  3:19 Condition signal.h inclusion in sys/wait.h (bug 21560) Joseph Myers
@ 2017-06-09 12:13 ` Zack Weinberg
  0 siblings, 0 replies; 2+ messages in thread
From: Zack Weinberg @ 2017-06-09 12:13 UTC (permalink / raw)
  To: Joseph Myers; +Cc: GNU C Library

On Thu, Jun 8, 2017 at 11:19 PM, Joseph Myers <joseph@codesourcery.com> wrote:
> sys/wait.h includes signal.h unconditionally.  But the permission to
> do so is UX-shaded in XPG4.2, and XSI-shaded in POSIX before 2008, so
> this should not be unconditional.  This patch fixes this
> conservatively: the include is kept, but conditioned on the standards
> that permit it (meaning it is still present by default, because
> non-XSI POSIX.1:2008 is enabled by default).  <bits/types.h> is now
> included unconditionally to provide the required definition of
> __pid_t; it was previously included via <signal.h>.  Some standards
> require pid_t to be defined here, and all allow it to be defined here;
> previously defined via <signal.h>, it's now defined directly in this
> header.
>
> Tested for x86_64.  This does not fix any of the sys/wait.h
> conformtest failures, but substantially reduces the number of
> namespace failures for sys/wait.h for XPG4 and POSIX.

This is OK.  We might want to think about removing the include
altogether in a future release, but that's probably not a good plan
this close to a release freeze.

zw

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-06-09 12:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-09  3:19 Condition signal.h inclusion in sys/wait.h (bug 21560) Joseph Myers
2017-06-09 12:13 ` Zack Weinberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).