FreeBSD Bugzilla – Attachment 205931 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]
proposed fix
patch-glib_gspawn.c (text/plain), 1.57 KB, created by
Eugene Grosbein
on 2019-07-20 13:14:23 UTC
(
hide
)
Description:
proposed fix
Filename:
MIME Type:
Creator:
Eugene Grosbein
Created:
2019-07-20 13:14:23 UTC
Size:
1.57 KB
patch
obsolete
>--- glib/gspawn.c.orig 2018-09-21 12:29:23.000000000 +0300 >+++ glib/gspawn.c 2019-07-20 15:37:26.923958000 +0300 >@@ -39,6 +39,13 @@ > #include <sys/resource.h> > #endif /* HAVE_SYS_RESOURCE_H */ > >+#ifdef __FreeBSD__ >+#include <sys/param.h> >+#include <sys/sysctl.h> >+#include <sys/types.h> >+#include <sys/user.h> >+#endif >+ > #include "gspawn.h" > #include "gthread.h" > #include "glib/gstdio.h" >@@ -1077,6 +1084,45 @@ set_cloexec (void *data, gint fd) > } > > #ifndef HAVE_FDWALK >+ >+#ifdef __FreeBSD__ >+static int >+fdwalk_s(int (*cb)(void *data, int fd), void *data, gint *resp) >+{ >+ char *bp, *ep; >+ int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_FILEDESC, 0}; >+ size_t len = 0; >+ struct kinfo_file kif; >+ >+ mib[3] = (int)getpid(); >+ >+ if (sysctl(mib, nitems(mib), NULL, &len, NULL, 0) != 0) >+ return FALSE; >+ >+ if ((bp = (char*) malloc(len)) == NULL) >+ return FALSE; >+ >+ if (sysctl(mib, nitems(mib), bp, &len, NULL, 0) != 0) { >+ free(bp); >+ return FALSE; >+ } >+ >+ ep = bp; >+ while (ep < bp + len) { >+ kif = *(struct kinfo_file*)ep; >+ 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) > { >@@ -1088,6 +1134,12 @@ fdwalk (int (*cb)(void *data, int fd), v > struct rlimit rl; > #endif > >+#ifdef __FreeBSD__ >+ if (fdwalk_s(cb, data, &res) == TRUE) >+ return res; >+ /* If any sysctl/malloc call fails continue with the fall back method */ >+#endif >+ > #ifdef __linux__ > DIR *d; >
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