<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>I have an issue on Mac OSX where the RTSPClient was throwing SIG_PIPE whenever the TCP connection from the server was terminated (server timeout or crash).</div><div>Trying to USE_SIGNALS as below did not work and we were still crashing when the connection was dropping:</div><div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "><span style="color: #88185d">#ifdef</span> USE_SIGNALS</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; color: rgb(68, 133, 103); "><span style="color: #000000"> </span>// Ignore the SIGPIPE signal, so that clients on the same host that are killed</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; color: rgb(68, 133, 103); "><span style="color: #000000"> </span>// don't also kill us:</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "> <span style="color: #6d3688">signal</span>(SIGPIPE, SIG_IGN);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; color: rgb(136, 24, 93); ">#endif</div></div><div><br></div><div>The only way we found to fix ti was to set SO_NOSIGPIPE on the socket itself when created.</div><div><br></div><div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; color: rgb(68, 133, 103); "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "> <span style="color: #88185d">if</span> (newSocket > 0) {</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "> <span style="color: #88185d">int</span> set_option = 1;</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "> <span style="color: #88185d">if</span> (0 == <span style="color: #6d3688">setsockopt</span>(newSocket, SOL_SOCKET, SO_NOSIGPIPE, &set_option, <span style="color: #88185d">sizeof</span>(set_option))) {</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "> } <span style="color: #88185d">else</span> {</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; color: rgb(49, 46, 255); "><span style="color: #000000"> <span class="Apple-tab-span" style="white-space:pre"> </span>socketErr(env,</span>"failed to set socket signal option"<span style="color: #000000">);</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "> }</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "> }</div></div><div><br></div><div>I have attached the source code with the change in <span class="Apple-style-span" style="color: rgb(49, 46, 255); font-family: Monaco; font-size: 11px; ">GroupsockHelper.cpp</span> . </div><div>Will it be possible to include that change in an upcoming release?</div></div></blockquote><div><br></div>No, because I don't want this behavior (ignoring SIGPIPE signals) to happen all the time. Instead, it should happen only when the developer specifically wants it.</div><div><br></div><div>In this case, what we want is for the RTSP server to ignore SIGPIPE signals that might get sent when clients (running on the same host) die. So the right place to do this is in the "RTSPServer" code, in the same place where we currently do:</div><div><div><span class="Apple-tab-span" style="white-space:pre"> </span>#ifdef USE_SIGNALS</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> // Ignore the SIGPIPE signal, so that clients on the same host that are killed</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> // don't also kill us:</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> signal(SIGPIPE, SIG_IGN);</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>#endif</div><div><br></div><div>What I might end up doing, therefore, is replace this code with:</div><div><div><span class="Apple-tab-span" style="white-space: pre; "> </span>#ifdef USE_SIGNALS</div><div><span class="Apple-tab-span" style="white-space: pre; "> </span> // Ignore the SIGPIPE signal, so that clients on the same host that are killed</div><div><span class="Apple-tab-span" style="white-space: pre; "> </span> // don't also kill us:</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>#ifdef SO_NOSIGPIPE</div><div><div> <span class="Apple-tab-span" style="white-space:pre"> </span>int set_option = 1;</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>setsockopt(ourSocket, SOL_SOCKET, SO_NOSIGPIPE, &set_option, sizeof set_option);</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>#else</div></div><div><span class="Apple-tab-span" style="white-space: pre; "> </span> signal(SIGPIPE, SIG_IGN);</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>#endif</div><div><span class="Apple-tab-span" style="white-space: pre; "> </span>#endif</div><div><br></div><div>I hope this will work for you...</div></div><div><br></div></div><br><br><div apple-content-edited="true">
<span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; ">Ross Finlayson<br>Live Networks, Inc.<br><a href="http://www.live555.com/">http://www.live555.com/</a></span></span>
</div>
<br></body></html>