Removed
Link Here
|
1 |
--- glib/gspawn.c.orig 2020-12-17 03:47:11.474608400 -0800 |
2 |
+++ glib/gspawn.c 2021-02-17 13:58:15.271434000 -0800 |
3 |
@@ -51,6 +51,12 @@ |
4 |
#include <sys/syscall.h> /* for syscall and SYS_getdents64 */ |
5 |
#endif |
6 |
|
7 |
+#ifdef __FreeBSD__ |
8 |
+#include <sys/types.h> |
9 |
+#include <sys/user.h> |
10 |
+#include <libutil.h> |
11 |
+#endif |
12 |
+ |
13 |
#include "gspawn.h" |
14 |
#include "gspawn-private.h" |
15 |
#include "gthread.h" |
16 |
@@ -1204,6 +1210,33 @@ filename_to_fd (const char *p) |
17 |
} |
18 |
#endif |
19 |
|
20 |
+#ifdef __FreeBSD__ |
21 |
+static int |
22 |
+fdwalk2(int (*func)(void *, int), void *udata, gint *ret) |
23 |
+{ |
24 |
+ struct kinfo_file *kf; |
25 |
+ int i, cnt; |
26 |
+ |
27 |
+ if (NULL == func) |
28 |
+ return EINVAL; |
29 |
+ |
30 |
+ kf = kinfo_getfile(getpid(), &cnt); |
31 |
+ if (kf == NULL) |
32 |
+ return ENOMEM; |
33 |
+ |
34 |
+ for (i = 0; i < cnt; i++) { |
35 |
+ if (0 > kf[i].kf_fd) |
36 |
+ continue; |
37 |
+ *ret = func (udata, kf[i].kf_fd); |
38 |
+ if (*ret != 0) |
39 |
+ break; |
40 |
+ } |
41 |
+ |
42 |
+ free(kf); |
43 |
+ return 0; |
44 |
+} |
45 |
+#endif |
46 |
+ |
47 |
/* This function is called between fork() and exec() and hence must be |
48 |
* async-signal-safe (see signal-safety(7)). */ |
49 |
static int |
50 |
@@ -1228,6 +1261,12 @@ safe_fdwalk (int (*cb)(void *data, int fd), void *data |
51 |
|
52 |
#if 0 && defined(HAVE_SYS_RESOURCE_H) |
53 |
struct rlimit rl; |
54 |
+#endif |
55 |
+ |
56 |
+#ifdef __FreeBSD__ |
57 |
+ if (fdwalk2(cb, data, &res) == 0) |
58 |
+ return res; |
59 |
+ /* If any sysctl/malloc call fails continue with the fall back method */ |
60 |
#endif |
61 |
|
62 |
#ifdef __linux__ |