Problem Description:
When the app is running, the lock screen is opened again with a chance to flash back. The discovery program is interrupted here by the real-machine debug:
Libsystem_kernel.dylib ' Mach_msg_trap:
Solution Ideas:
- This article understands that the process receives the Sigpipe signal, and the default behavior of the signal is to terminate the process.
The process received A sigpipe . The default behaviour for this signal are to end the process.
A sigpipe is sent to a process if it tried to write to a socket that had be En shutdown for writing or isn ' t connected (anymore).
To avoid the program ends in this case, you could either
- make the process ignore sigpipe or
- Install a explicit h Andler for sigpipe (typically doing nothing).
In both Cases send* () / write () would return -1
and set errno to epipe .
Sigpipe Related Information
- As noted in the Apple documentation:
When the connection is closed, the process receives the sigpipe signal by default. If the signal is not processed or ignored, the program exits immediately.
Two sets of solutions are given in the documentation:
When a connection closes is, by default, your process receives a sigpipe signal. If Your program does isn't handle or ignore this signal, the your program would quit immediately. You can handle this in one of the ways:
- Ignore the signal globally with the following line of code:
Signal (Sigpipe, sig_ign);
- Tell the socket isn't to send the signal in the first place with the following lines of code (substituting the variable cont Aining your socket in place of sock):
int 1 sizeof(value));
For maximum compatibility, the should set this flag on each incoming socket immediately after calling accept in addition t o Setting the flag on the listening socket itself.
Avoiding Common Networking Mistakes content (from Apple)
- Find a third solution in the well-known stack overflow stackoverflow Web site (msg_nosignal cannot be tested because it is not defined in Mac OS):
If you ' re using the-the- send () call, another option was to use the msg_nosignal option, which'll turn the C3>sigpipe behavior off on a per call basis. Note that isn't all operating systems support the msg_nosignal flag.
Reference Links:
1.iOS Exception Handling: Mach_msg_trap exception-Http://www.jianshu.com/p/2b3f58c61d7d
2. How to avoid sigpipe signal caused by crash (avoiding sigpipe signal crash in iOS) on iOS-http://www.jianshu.com/p/1957d2b18d2c
3.Program received signal sigpipe, broken pipe.? -Https://stackoverflow.com/questions/18935446/program-received-signal-sigpipe-broken-pipe
4.How to prevent sigpipes (or handle them properly)-https://stackoverflow.com/questions/108183/ How-to-prevent-sigpipes-or-handle-them-properly
5.Avoiding Common Networking mistakes-https://developer.apple.com/library/content/documentation/ Networkinginternetweb/conceptual/networkingoverview/commonpitfalls/commonpitfalls.html
Avoid sigpipe caused by iOS app flashback/avoiding Sigpipe signal crash in iOS (Mach_msg_trap, sigpipe signal)