Fixed some embarassing errors
[reactos.git] / posix / lib / psxdll / unistd / getpid.c
1 /* $Id: getpid.c,v 1.3 2002/05/17 01:55:34 hyperion Exp $
2 */
3 /*
4 * COPYRIGHT: See COPYING in the top level directory
5 * PROJECT: ReactOS POSIX+ Subsystem
6 * FILE: subsys/psx/lib/psxdll/unistd/getpid.c
7 * PURPOSE: Get the process ID
8 * PROGRAMMER: KJK::Hyperion <noog@libero.it>
9 * UPDATE HISTORY:
10 * 15/02/2002: Created
11 */
12
13 #include <ddk/ntddk.h>
14 #include <sys/types.h>
15 #include <unistd.h>
16 #include <psx/errno.h>
17
18 pid_t getpid(void)
19 {
20 PROCESS_BASIC_INFORMATION pbiInfo;
21 NTSTATUS nErrCode;
22
23 nErrCode = NtQueryInformationProcess
24 (
25 NtCurrentProcess(),
26 ProcessBasicInformation,
27 &pbiInfo,
28 sizeof(pbiInfo),
29 NULL
30 );
31
32 if(!NT_SUCCESS(nErrCode))
33 {
34 errno = __status_to_errno(nErrCode);
35 return (0);
36 }
37
38 return (pbiInfo.UniqueProcessId);
39 #if 0
40 return ((pid_t)NtCurrentTeb()->Cid.UniqueProcess);
41 #endif
42 }
43
44 /* EOF */
45