Re: [Darwin-Dev] open file descriptors for a process?
site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com #include <libproc.h> #include <sys/proc_info.h> #include <stdlib.h> int num_fd_for_pid(pid_t pid) { struct proc_fdinfo *temp_buffer; int pidinfo_result, result; pidinfo_result = proc_pidinfo(pid, PROC_PIDLISTFDS, 0, NULL, 0); if (pidinfo_result <= 0) return pidinfo_result; temp_buffer = malloc(pidinfo_result); pidinfo_result = proc_pidinfo(pid, PROC_PIDLISTFDS, 0, temp_buffer, pidinfo_result); free(temp_buffer); if (pidinfo_result <= 0) return pidinfo_result; result = (pidinfo_result / PROC_PIDLISTFD_SIZE); return result; } Just whipped that up, seems to work but no guarantees yada yada. Also, libproc.h states: /* * This header file contains private interfaces to obtain process information. * These interfaces are subject to change in future releases. */ _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... This email sent to site_archiver@lists.apple.com
participants (1)
-
Dave Keck