Red Hat Bugzilla – Bug 812
unistd.h fails to define pid_t
Last modified: 2008-05-01 11:37:48 EDT
unistd.h is supposed to define pid_t. It doesn't.
Here's a test case.
$ cat test.c
pid = getpid();
$ make test
cc test.c -o test
test.c: In function `main':
test.c:5: `pid_t' undeclared (first use this function)
test.c:5: (Each undeclared identifier is reported only once
test.c:5: for each function it appears in.)
test.c:5: parse error before `pid'
test.c:6: `pid' undeclared (first use this function)
make: *** [test] Error 1
Add -D_GNU_SOURCE to your compile line. Then it works for me, on the
Looking at unistd.h the pid_t define is wrapped around: __USE_XOPEN