According to POSIX:2008 <http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sched.h.html> 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'
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;
This is fixed in current glibc (tested 2.14).