Bug 13198 - sched.h should define pid_t
Summary: sched.h should define pid_t
Alias: None
Product: glibc
Classification: Unclassified
Component: libc (show other bugs)
Version: 2.11
: P2 normal
Target Milestone: ---
Assignee: Ulrich Drepper
Depends on:
Reported: 2011-09-18 21:22 UTC by Bruno Haible
Modified: 2014-06-27 12:03 UTC (History)
2 users (show)

See Also:
Last reconfirmed:
fweimer: security-


Note You need to log in before you can comment on or make changes to this bug.
Description Bruno Haible 2011-09-18 21:22:00 UTC
According to POSIX:2008
the <sched.h> header should ensure that the pid_t type gets defined, like
<sys/types.h> does, if the "Process Scheduling" features of POSIX are supported.

In this header, these features consist of the functions sched_get_priority_max,
sched_get_priority_min, sched_getparam, sched_getscheduler, sched_rr_get_interval,
sched_setparam, sched_setscheduler - which are all supported by glibc.
So I believe the intent is that glibc supports the "Process Scheduling" features.
But then <sched.h> should define 'pid_t'.

How to reproduce:
================= bug.c ================
#include <sched.h>
pid_t x;

$ gcc -c bug.c
bug.c:2:7: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'x'
$ gcc -c -D_GNU_SOURCE bug.c
bug.c:2:7: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'x'
Comment 1 Eric Blake 2011-09-19 22:15:42 UTC
This appears to be fixed by at least glibc 2.13:

$ printf '#include<sched.h>\n' | gcc -E - | grep pid_t | head -n2
typedef int __pid_t;
typedef __pid_t pid_t;
$ printf '#define _POSIX_C_SOURCE 200809L\n#include<sched.h>\n' \
  | gcc -E - | grep pid_t | head -n2
typedef int __pid_t;
typedef __pid_t pid_t;
Comment 2 Andreas Jaeger 2011-09-28 12:21:35 UTC
This is fixed in current glibc (tested 2.14).