Lines 39-44
Link Here
|
39 |
#include <sys/resource.h> |
39 |
#include <sys/resource.h> |
40 |
#endif /* HAVE_SYS_RESOURCE_H */ |
40 |
#endif /* HAVE_SYS_RESOURCE_H */ |
41 |
|
41 |
|
|
|
42 |
#ifdef __FreeBSD__ |
43 |
#include <sys/param.h> |
44 |
#include <sys/sysctl.h> |
45 |
#include <sys/types.h> |
46 |
#include <sys/user.h> |
47 |
#endif |
48 |
|
42 |
#include "gspawn.h" |
49 |
#include "gspawn.h" |
43 |
#include "gthread.h" |
50 |
#include "gthread.h" |
44 |
#include "glib/gstdio.h" |
51 |
#include "glib/gstdio.h" |
Lines 1126-1132
Link Here
|
1126 |
* rlimit trick */ |
1133 |
* rlimit trick */ |
1127 |
|
1134 |
|
1128 |
#endif |
1135 |
#endif |
|
|
1136 |
|
1137 |
#ifdef __FreeBSD__ |
1138 |
char *bp = NULL; |
1139 |
char *ep = NULL; |
1140 |
size_t len = 0; |
1141 |
int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_FILEDESC, (int)getpid()}; |
1129 |
|
1142 |
|
|
|
1143 |
if (sysctl(mib, nitems(mib), NULL, &len, NULL, 0) == 0) |
1144 |
{ |
1145 |
bp = (char*) malloc(len); |
1146 |
if (sysctl(mib, nitems(mib), bp, &len, NULL, 0) == 0) |
1147 |
{ |
1148 |
ep = bp; |
1149 |
while (ep < bp + len) { |
1150 |
struct kinfo_file kif = *(struct kinfo_file*)ep; |
1151 |
ep += kif.kf_structsize; |
1152 |
if (kif.kf_fd < 0) |
1153 |
continue; |
1154 |
|
1155 |
if ((res = cb (data, kif.kf_fd)) != 0) |
1156 |
break; |
1157 |
} |
1158 |
|
1159 |
free(bp); |
1160 |
return res; |
1161 |
} |
1162 |
free(bp); |
1163 |
} |
1164 |
/* If any sysctl call fails continue with the fall back method */ |
1165 |
#endif |
1166 |
|
1130 |
#ifdef HAVE_SYS_RESOURCE_H |
1167 |
#ifdef HAVE_SYS_RESOURCE_H |
1131 |
|
1168 |
|
1132 |
if (getrlimit(RLIMIT_NOFILE, &rl) == 0 && rl.rlim_max != RLIM_INFINITY) |
1169 |
if (getrlimit(RLIMIT_NOFILE, &rl) == 0 && rl.rlim_max != RLIM_INFINITY) |