mirror of
https://github.com/tmux/tmux.git
synced 2025-12-17 00:02:23 -05:00
Implement getdtablecount(3) for Darwin, from Chip Davis in GitHub issue 4636.
This commit is contained in:
parent
3e28777ecb
commit
0ff2676a25
@ -18,13 +18,28 @@
|
|||||||
|
|
||||||
#include <glob.h>
|
#include <glob.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#if defined(HAVE_LIBPROC_H)
|
||||||
|
#include <libproc.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "compat.h"
|
#include "compat.h"
|
||||||
|
|
||||||
void fatal(const char *, ...);
|
void fatal(const char *, ...);
|
||||||
void fatalx(const char *, ...);
|
void fatalx(const char *, ...);
|
||||||
|
|
||||||
#ifdef HAVE_PROC_PID
|
#if defined(HAVE_LIBPROC_H) && defined(HAVE_PROC_PIDINFO)
|
||||||
|
int
|
||||||
|
getdtablecount(void)
|
||||||
|
{
|
||||||
|
int sz;
|
||||||
|
pid_t pid = getpid();
|
||||||
|
|
||||||
|
sz = proc_pidinfo(pid, PROC_PIDLISTFDS, 0, NULL, 0);
|
||||||
|
if (sz == -1)
|
||||||
|
return (0);
|
||||||
|
return (sz / PROC_PIDLISTFD_SIZE);
|
||||||
|
}
|
||||||
|
#elif defined(HAVE_PROC_PID)
|
||||||
int
|
int
|
||||||
getdtablecount(void)
|
getdtablecount(void)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user