mirror of
				https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
				synced 2025-11-03 09:01:50 -05:00 
			
		
		
		
	core-util: introduce pa_disable_sigpipe()
This commit is contained in:
		
							parent
							
								
									ebce3185ef
								
							
						
					
					
						commit
						759a9d0cc5
					
				
					 4 changed files with 27 additions and 4 deletions
				
			
		| 
						 | 
				
			
			@ -946,9 +946,7 @@ int main(int argc, char *argv[]) {
 | 
			
		|||
        valid_pid_file = TRUE;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
#ifdef SIGPIPE
 | 
			
		||||
    signal(SIGPIPE, SIG_IGN);
 | 
			
		||||
#endif
 | 
			
		||||
    pa_disable_sigpipe();
 | 
			
		||||
 | 
			
		||||
    if (pa_rtclock_hrtimer())
 | 
			
		||||
        pa_log_info(_("Fresh high-resolution timers available! Bon appetit!"));
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2711,3 +2711,24 @@ char *pa_realpath(const char *path) {
 | 
			
		|||
 | 
			
		||||
    return t;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void pa_disable_sigpipe(void) {
 | 
			
		||||
 | 
			
		||||
#ifdef SIGPIPE
 | 
			
		||||
    struct sigaction sa;
 | 
			
		||||
 | 
			
		||||
    pa_zero(sa);
 | 
			
		||||
 | 
			
		||||
    if (sigaction(SIGPIPE, NULL, &sa) < 0) {
 | 
			
		||||
        pa_log("sigaction(): %s", pa_cstrerror(errno));
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    sa.sa_handler = SIG_IGN;
 | 
			
		||||
 | 
			
		||||
    if (sigaction(SIGPIPE, &sa, NULL) < 0) {
 | 
			
		||||
        pa_log("sigaction(): %s", pa_cstrerror(errno));
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -227,4 +227,6 @@ char *pa_unescape(char *p);
 | 
			
		|||
 | 
			
		||||
char *pa_realpath(const char *path);
 | 
			
		||||
 | 
			
		||||
void pa_disable_sigpipe(void);
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -30,6 +30,8 @@
 | 
			
		|||
#include <pulse/pulseaudio.h>
 | 
			
		||||
#include <pulse/browser.h>
 | 
			
		||||
 | 
			
		||||
#include <pulsecore/core-util.h>
 | 
			
		||||
 | 
			
		||||
static void exit_signal_callback(pa_mainloop_api*m, pa_signal_event *e, int sig, void *userdata) {
 | 
			
		||||
    fprintf(stderr, "Got signal, exiting\n");
 | 
			
		||||
    m->quit(m, 0);
 | 
			
		||||
| 
						 | 
				
			
			@ -127,7 +129,7 @@ int main(int argc, char *argv[]) {
 | 
			
		|||
    assert(r == 0);
 | 
			
		||||
    pa_signal_new(SIGINT, exit_signal_callback, NULL);
 | 
			
		||||
    pa_signal_new(SIGTERM, exit_signal_callback, NULL);
 | 
			
		||||
    signal(SIGPIPE, SIG_IGN);
 | 
			
		||||
    pa_disable_sigpipe();
 | 
			
		||||
 | 
			
		||||
    if (!(browser = pa_browser_new_full(pa_mainloop_get_api(mainloop), PA_BROWSE_FOR_SERVERS|PA_BROWSE_FOR_SINKS|PA_BROWSE_FOR_SOURCES, &s))) {
 | 
			
		||||
        fprintf(stderr, "pa_browse_new_full(): %s\n", s);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue