Fixed some embarassing errors
[reactos.git] / posix / lib / psxdll / unistd / getpid.c
index 4a701b3..a336a15 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: getpid.c,v 1.2 2002/02/20 09:17:58 hyperion Exp $
+/* $Id: getpid.c,v 1.3 2002/05/17 01:55:34 hyperion Exp $
  */
 /*
  * COPYRIGHT:   See COPYING in the top level directory
 #include <ddk/ntddk.h>
 #include <sys/types.h>
 #include <unistd.h>
+#include <psx/errno.h>
 
 pid_t getpid(void)
 {
- return ((pid_t)NtCurrentTeb()->Cid.UniqueThread);
+ PROCESS_BASIC_INFORMATION pbiInfo;
+ NTSTATUS                  nErrCode;
+
+ nErrCode = NtQueryInformationProcess
+ (
+  NtCurrentProcess(),
+  ProcessBasicInformation,
+  &pbiInfo,
+  sizeof(pbiInfo),
+  NULL
+ );
+
+ if(!NT_SUCCESS(nErrCode))
+ {
+  errno = __status_to_errno(nErrCode);
+  return (0);
+ }
+
+ return (pbiInfo.UniqueProcessId);
+#if 0
+ return ((pid_t)NtCurrentTeb()->Cid.UniqueProcess);
+#endif
 }
 
 /* EOF */