Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2019
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <errno.h>
  5. #include <libproc.h>
  6.  
  7. int main (int argc, char* argv[])
  8. {
  9. pid_t pid; int ret;
  10. char pathbuf[PROC_PIDPATHINFO_MAXSIZE];
  11.  
  12. if ( argc > 1 ) {
  13. pid = (pid_t) atoi(argv[1]);
  14. ret = proc_pidpath (pid, pathbuf, sizeof(pathbuf));
  15. if ( ret <= 0 ) {
  16. fprintf(stderr, "PID %d: proc_pidpath ();\n", pid);
  17. fprintf(stderr, " %s\n", strerror(errno));
  18. } else {
  19. printf("proc %d: %s\n", pid, pathbuf);
  20. }
  21. }
  22.  
  23. return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement