Advertisement
wfaulk

Solaris mmap() lsof test program

Oct 23rd, 2013
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.57 KB | None | 0 0
  1. #include <sys/types.h>
  2. #include <sys/stat.h>
  3. #include <fcntl.h>
  4. #include <sys/mman.h>
  5. #include <unistd.h>
  6. #include <stdio.h>
  7. #include <stdlib.h>
  8.  
  9. int main() {
  10.         int fildes;
  11.         void* address;
  12.         char lsofcmd[1024];
  13.         int pid;
  14.  
  15.         fildes = open("/etc/passwd", O_RDONLY);
  16.         address = mmap((caddr_t)0, (size_t)1024, PROT_READ, MAP_PRIVATE, fildes, (off_t)0);
  17.  
  18.         pid=(int)getpid();
  19.         sprintf(lsofcmd, "lsof -p %d", pid);
  20.  
  21.         system(lsofcmd);
  22.  
  23.         close(fildes);
  24.  
  25.         system(lsofcmd);
  26.  
  27.         return(0);
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement