home *** CD-ROM | disk | FTP | other *** search
/ PC Extra Super CD 1998 January / PCPLUS131.iso / DJGPP / V2 / DJLSR201.ZIP / src / libc / posix / unistd / getpid.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-01-25  |  482 b   |  24 lines

  1. /* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */
  2. /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
  3. #include <unistd.h>
  4. #include <go32.h>
  5. #include <libc/farptrgs.h>
  6. #include <libc/bss.h>
  7.  
  8. static int pid_count = -1;
  9. static pid_t my_pid;
  10.  
  11. pid_t
  12. getpid(void)
  13. {
  14.   if (pid_count != __bss_count)
  15.   {
  16.     pid_count = __bss_count;
  17.     my_pid = _farpeekw(_dos_ds, 0x46c);
  18.     my_pid &= 0x3fff;
  19.     my_pid |= 0x1000;
  20.   }
  21.  
  22.   return my_pid;
  23. }
  24.