1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- $OpenBSD: patch-src_pulse_util_c,v 1.9 2015/04/05 10:12:34 ajacoutot Exp $
- Implement pa_get_binary_name().
- --- src/pulse/util.c.orig Thu Feb 12 15:10:35 2015
- +++ src/pulse/util.c Sun Apr 5 11:46:45 2015
- @@ -52,6 +52,11 @@
- #include <sys/sysctl.h>
- #endif
-
- +#ifdef __OpenBSD__
- +#include <libgen.h>
- +#include <sys/sysctl.h>
- +#endif
- +
- #include <pulse/xmalloc.h>
- #include <pulse/timeval.h>
-
- @@ -224,6 +229,30 @@ char *pa_get_binary_name(char *s, size_t l) {
- }
- }
- #endif
- +
- +#ifdef __OpenBSD__
- + {
- + size_t len;
- + char **buf;
- +
- + int mib[] = { CTL_KERN, KERN_PROC_ARGS, getpid(), KERN_PROC_ARGV };
- +
- + if (sysctl (mib, 4, NULL, &len, NULL, 0) == -1)
- + return NULL;
- +
- + buf = (char *) pa_xmalloc(len);
- +
- + if (sysctl(mib, 4, buf, &len, NULL, 0) == 0) {
- + pa_strlcpy(s, basename(*buf), l);
- + pa_xfree(buf);
- + return s;
- + }
- +
- + pa_xfree(buf);
- +
- + /* fall thru */
- + }
- +#endif /* __OpenBSD__ */
-
- #if defined(HAVE_DLADDR) && defined(PA_GCC_WEAKREF)
- {
|