Description: fix -i (background) option to not require a tty
Author: Jeff King <peff-debbug@peff.net>
Reviewed-by: Junichi Uekawa <dancer@debian.org>
Bug-Debian: http://bugs.debian.org/206319
Last-Update: 2011-08-16
diff -urN xphoon-20000613.orig/xphoon.c xphoon-20000613/xphoon.c
--- xphoon-20000613.orig/xphoon.c	2000-06-13 23:50:16.000000000 +0200
+++ xphoon-20000613/xphoon.c	2011-08-16 21:45:41.000000000 +0200
@@ -25,6 +25,7 @@
 #include <math.h>
 #include <limits.h>	/* added by Lalo Martins */
 #include <sys/ioctl.h>
+#include <errno.h>	/* added by Jeff King */
 #include "tws.h"
 
 
@@ -202,9 +203,14 @@
 	tty = open( "/dev/tty", 0 );
 	if ( tty < 0 )
 	    {
-	    (void) fprintf( stderr, "%s: ", argv0 );
-	    perror( "/dev/tty open" );
-	    exit( 1 );
+	    /* if we don't have a tty, don't flag an error 
+	     * Jeff King, Aug 20 2003 */
+	    if ( errno != ENXIO )
+		{
+		(void) fprintf( stderr, "%s: ", argv0 );
+		perror( "/dev/tty open" );
+		exit( 1 );
+		}
 	    }
 	else
 	    {
