Linux Media Controller development
 help / color / mirror / Atom feed
* gnutv should not ignore SIGPIPE
@ 2011-11-25 13:05 Brian J. Murrell
  2011-11-25 13:34 ` Rémi Denis-Courmont
  0 siblings, 1 reply; 4+ messages in thread
From: Brian J. Murrell @ 2011-11-25 13:05 UTC (permalink / raw)
  To: linux-media

[-- Attachment #1: Type: text/plain, Size: 431 bytes --]

Currently, (at least in rev. 1355) gnutv is ignoring SIGPIPE:

	signal(SIGPIPE, SIG_IGN);

This means though that if it is used as such:

gnutv -out stdout -channels /home/mythtv/channels.conf.found 91-472 |
mplayer -

It will not terminate as it should when/if it's consumer (mplayer in
the above example) is killed.

Is there a good reason I am not seeing why gnutv should be ignoring
SIGPIPE?

Cheers,
b.




[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 262 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: gnutv should not ignore SIGPIPE
  2011-11-25 13:05 gnutv should not ignore SIGPIPE Brian J. Murrell
@ 2011-11-25 13:34 ` Rémi Denis-Courmont
  2011-11-25 13:36   ` Brian J. Murrell
  0 siblings, 1 reply; 4+ messages in thread
From: Rémi Denis-Courmont @ 2011-11-25 13:34 UTC (permalink / raw)
  To: Brian J. Murrell; +Cc: linux-media

Le vendredi 25 novembre 2011 15:05:44 Brian J. Murrell, vous avez écrit :
> Is there a good reason I am not seeing why gnutv should be ignoring
> SIGPIPE?

In general, ignoring SIGPIPE is the easiest way to protect against denial of 
service when a peer connection socket is hung up remotely. MSG_NOSIGNAL is a 
more modern alternative.

Anyway, the problem is not so mucgh ignoring SIGPIPE as ignoring EPIPE write 
errors.

-- 
Rémi Denis-Courmont
http://www.remlab.net/
http://fi.linkedin.com/in/remidenis

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: gnutv should not ignore SIGPIPE
  2011-11-25 13:34 ` Rémi Denis-Courmont
@ 2011-11-25 13:36   ` Brian J. Murrell
  2011-11-29 14:22     ` Brian J. Murrell
  0 siblings, 1 reply; 4+ messages in thread
From: Brian J. Murrell @ 2011-11-25 13:36 UTC (permalink / raw)
  To: linux-media

[-- Attachment #1: Type: text/plain, Size: 285 bytes --]

On 11-11-25 08:34 AM, Rémi Denis-Courmont wrote:
> 
> Anyway, the problem is not so mucgh ignoring SIGPIPE as ignoring EPIPE write 
> errors.

Yes, that is the other way to skin that cat I suppose.

What's the best/proper way to go about getting this fixed?

Cheers,
b.



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 262 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: gnutv should not ignore SIGPIPE
  2011-11-25 13:36   ` Brian J. Murrell
@ 2011-11-29 14:22     ` Brian J. Murrell
  0 siblings, 0 replies; 4+ messages in thread
From: Brian J. Murrell @ 2011-11-29 14:22 UTC (permalink / raw)
  To: linux-media

[-- Attachment #1: Type: text/plain, Size: 1212 bytes --]

On 11-11-25 08:36 AM, Brian J. Murrell wrote:
> 
> Yes, that is the other way to skin that cat I suppose.

I couldn't figure out what the right thing for writer thread to do to
terminate the application so I used SIGPIPE instead.  Here's the patch:

--- linuxtv-dvb-apps-1.1.1+rev1273~/util/gnutv/gnutv_data.c	2011-11-28 09:10:33.010407011 -0500
+++ linuxtv-dvb-apps-1.1.1+rev1273/util/gnutv/gnutv_data.c	2011-11-28 09:10:26.446258282 -0500
@@ -265,7 +265,10 @@
 		while(written < size) {
 			int tmp = write(outfd, buf + written, size - written);
 			if (tmp == -1) {
-				if (errno != EINTR) {
+				if (errno == EPIPE) {
+					fprintf(stderr, "processing EPIPE\n");
+					return 0;
+				} else if (errno != EINTR) {
 					fprintf(stderr, "Write error: %m\n");
 					break;
 				}
--- linuxtv-dvb-apps-1.1.1+rev1273~/util/gnutv/gnutv.c	2011-11-28 10:13:13.294445131 -0500
+++ linuxtv-dvb-apps-1.1.1+rev1273/util/gnutv/gnutv.c.new	2011-11-28 10:13:10.510492321 -0500
@@ -262,7 +262,7 @@
 
 	// setup any signals
 	signal(SIGINT, signal_handler);
-	signal(SIGPIPE, SIG_IGN);
+	signal(SIGPIPE, signal_handler);
 
 	// start the CA stuff
 	gnutv_ca_params.adapter_id = adapter_id;


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 262 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-11-29 14:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-25 13:05 gnutv should not ignore SIGPIPE Brian J. Murrell
2011-11-25 13:34 ` Rémi Denis-Courmont
2011-11-25 13:36   ` Brian J. Murrell
2011-11-29 14:22     ` Brian J. Murrell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox