Subject: bin/33623: ping's SIGINFO handling prevents it from running in the background on tty
To: None <gnats-admin@netbsd.org, netbsd-bugs@netbsd.org>
From: None <chuck@netbsd.org>
List: netbsd-bugs
Date: 06/01/2006 14:55:01
>Number:         33623
>Category:       bin
>Synopsis:       ping's SIGINFO handling prevents it from running in the background on a tty
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Jun 01 14:55:01 +0000 2006
>Originator:     Chuck Cranor
>Release:        NetBSD 3.0
>Organization:
CMU
>Environment:

NetBSD xxx.pdl.cmu.edu 3.0 NetBSD 3.0 (XXX) #0: Thu Jan 19 14:18:58 EST 2006  chuck@bum.pdl.cmu.edu:/home/netbsd/30/src/sys/arch/i386/compile/XXX i386

Architecture: i386
Machine: i386
>Description:

	running ping with stdin attached to a tty in the background causes
	its process group to be STOPd  (state "T" in ps).

	stack trace:

	(gdb) where
	#0  0xbdba0a2f in ioctl () from /lib/libc.so.12
	#1  0xbdb507aa in tcsetattr () from /lib/libc.so.12
	#2  0x08049b71 in main ()
	#3  0x08048ff6 in ___start ()
	(gdb) quit


>How-To-Repeat:

	Try and run ping in the background on a tty (see below).

	Alternately: 
	 - install pkgsrc/net/nagios-base
	 - start nagios by hand from a tty (as explained in the docs)
		"nagios -d nagios.cfg"
	 - configure it to probe a host using the ping check
		/usr/pkg/libexec/nagios/check_ping
	 - note that probe processes freeze in "T" state due to bug

	[repeat with "nagios -d nagios.cfg </dev/null" and problem will
	 not occur]

	xxx[4]> ping -q -c 1 localhost
	PING localhost (127.0.0.1): 56 data bytes

	----localhost PING Statistics----
	1 packets transmitted, 1 packets received, 0.0% packet loss
	round-trip min/avg/max/stddev = 0.083/0.083/0.083/0.000 ms
	xxx[5]> ping -q -c 1 localhost &
		[1] 8896
	xxx[6]> PING localhost (127.0.0.1): 56 data bytes

	[1]  + Suspended (tty output)        ping -q -c 1 localhost
	xxx[6]> 

>Fix:

	do not attempt to change tty settings if we are not in the
	foreground?