FreeBSD Bugzilla – Attachment 207442 Details for
Bug 236815
[patch] devel/glib20: loops over all possible file descriptors
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
glib patch
patch-glib_gspawn.c (text/plain), 1.58 KB, created by
Ivan Rozhuk
on 2019-09-12 22:54:04 UTC
(
hide
)
Description:
glib patch
Filename:
MIME Type:
Creator:
Ivan Rozhuk
Created:
2019-09-12 22:54:04 UTC
Size:
1.58 KB
patch
obsolete
>--- glib/gspawn.c 2018-09-21 12:29:23.000000000 +0300 >+++ glib/gspawn.c 2019-07-20 18:05:15.486558000 +0300 >@@ -39,6 +39,12 @@ > #include <sys/resource.h> > #endif /* HAVE_SYS_RESOURCE_H */ > >+#ifdef __FreeBSD__ >+#include <sys/param.h> >+#include <sys/sysctl.h> >+#include <sys/user.h> >+#endif >+ > #include "gspawn.h" > #include "gthread.h" > #include "glib/gstdio.h" >@@ -1077,7 +1083,46 @@ > } > > #ifndef HAVE_FDWALK >+ >+#ifdef __FreeBSD__ > static int >+fdwalk_s(int (*cb)(void *data, int fd), void *data, gint *resp) >+{ >+ char *bp, *bp_end, *ep; >+ int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_FILEDESC, (int)getpid()}; >+ size_t len = 0; >+ struct kinfo_file kif; >+ >+ if (sysctl(mib, nitems(mib), NULL, &len, NULL, 0) != 0) >+ return FALSE; >+ >+ len += 4096; /* Additional space in case new files opened. */ >+ if ((bp = (char*) malloc(len)) == NULL) >+ return FALSE; >+ >+ if (sysctl(mib, nitems(mib), bp, &len, NULL, 0) != 0) { >+ free(bp); >+ return FALSE; >+ } >+ >+ ep = bp; >+ bp_end = (bp + len); >+ while (ep < bp_end) { >+ memcpy(&kif, ep, sizeof(struct kinfo_file)); >+ ep += kif.kf_structsize; >+ if (kif.kf_fd < 0) >+ continue; >+ >+ if ((*resp = cb (data, kif.kf_fd)) != 0) >+ break; >+ } >+ >+ free(bp); >+ return TRUE; >+} >+#endif >+ >+static int > fdwalk (int (*cb)(void *data, int fd), void *data) > { > gint open_max; >@@ -1086,6 +1131,12 @@ > > #ifdef HAVE_SYS_RESOURCE_H > struct rlimit rl; >+#endif >+ >+#ifdef __FreeBSD__ >+ if (fdwalk_s(cb, data, &res)) >+ return res; >+ /* If any sysctl/malloc call fails continue with the fall back method */ > #endif > > #ifdef __linux__
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 236815
:
205914
|
205931
|
205937
|
207442
|
207479
|
209087
|
218218