mirror of
				https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
				synced 2025-11-03 09:01:50 -05:00 
			
		
		
		
	util: Implement pa_get_binary_name() for Mac OS X
This commit is contained in:
		
							parent
							
								
									2a44304bee
								
							
						
					
					
						commit
						7a3b3a3763
					
				
					 1 changed files with 26 additions and 0 deletions
				
			
		| 
						 | 
					@ -49,6 +49,11 @@
 | 
				
			||||||
#include <sys/prctl.h>
 | 
					#include <sys/prctl.h>
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef OS_IS_DARWIN
 | 
				
			||||||
 | 
					#include <libgen.h>
 | 
				
			||||||
 | 
					#include <sys/sysctl.h>
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <pulse/xmalloc.h>
 | 
					#include <pulse/xmalloc.h>
 | 
				
			||||||
#include <pulse/timeval.h>
 | 
					#include <pulse/timeval.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -221,6 +226,27 @@ char *pa_get_binary_name(char *s, size_t l) {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef OS_IS_DARWIN
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        int mib[] = { CTL_KERN, KERN_PROCARGS, getpid(), 0 };
 | 
				
			||||||
 | 
					        size_t len, nmib = (sizeof(mib) / sizeof(mib[0])) - 1;
 | 
				
			||||||
 | 
					        char *buf;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        sysctl(mib, nmib, NULL, &len, NULL, 0);
 | 
				
			||||||
 | 
					        buf = (char *) pa_xmalloc(len);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (sysctl(mib, nmib, buf, &len, NULL, 0) == 0) {
 | 
				
			||||||
 | 
					            pa_strlcpy(s, basename(buf), l);
 | 
				
			||||||
 | 
					            pa_xfree(buf);
 | 
				
			||||||
 | 
					            return s;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        pa_xfree(buf);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /* fall thru */
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					#endif /* OS_IS_DARWIN */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    errno = ENOENT;
 | 
					    errno = ENOENT;
 | 
				
			||||||
    return NULL;
 | 
					    return NULL;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue