patch-src_pulse_util_c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. $OpenBSD: patch-src_pulse_util_c,v 1.9 2015/04/05 10:12:34 ajacoutot Exp $
  2. Implement pa_get_binary_name().
  3. --- src/pulse/util.c.orig Thu Feb 12 15:10:35 2015
  4. +++ src/pulse/util.c Sun Apr 5 11:46:45 2015
  5. @@ -52,6 +52,11 @@
  6. #include <sys/sysctl.h>
  7. #endif
  8. +#ifdef __OpenBSD__
  9. +#include <libgen.h>
  10. +#include <sys/sysctl.h>
  11. +#endif
  12. +
  13. #include <pulse/xmalloc.h>
  14. #include <pulse/timeval.h>
  15. @@ -224,6 +229,30 @@ char *pa_get_binary_name(char *s, size_t l) {
  16. }
  17. }
  18. #endif
  19. +
  20. +#ifdef __OpenBSD__
  21. + {
  22. + size_t len;
  23. + char **buf;
  24. +
  25. + int mib[] = { CTL_KERN, KERN_PROC_ARGS, getpid(), KERN_PROC_ARGV };
  26. +
  27. + if (sysctl (mib, 4, NULL, &len, NULL, 0) == -1)
  28. + return NULL;
  29. +
  30. + buf = (char *) pa_xmalloc(len);
  31. +
  32. + if (sysctl(mib, 4, buf, &len, NULL, 0) == 0) {
  33. + pa_strlcpy(s, basename(*buf), l);
  34. + pa_xfree(buf);
  35. + return s;
  36. + }
  37. +
  38. + pa_xfree(buf);
  39. +
  40. + /* fall thru */
  41. + }
  42. +#endif /* __OpenBSD__ */
  43. #if defined(HAVE_DLADDR) && defined(PA_GCC_WEAKREF)
  44. {