Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ios - signal function with SIGPIPE and SIG_IGN

Tags:

ios

I have joined in a old project and I found this line

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    signal(SIGPIPE, SIG_IGN);
    ....
}

I have found in docs this:

/*
 * For historical reasons; programs expect signal's return value to be
 * defined by <sys/signal.h>.
 */

But I'm still confused as to what the purpose of that line is.

like image 906
Ricardo Avatar asked Mar 12 '23 02:03

Ricardo


1 Answers

From Apple's documentation:

When a connection closes, by default, your process receives a SIGPIPE signal. If your program does not handle or ignore this signal, your program will quit immediately.

Ignore the signal globally with the following line of code: signal(SIGPIPE, SIG_IGN);

like image 119
Rodrigo de Santiago Avatar answered Mar 20 '23 06:03

Rodrigo de Santiago