Subject: bin/2705: pppd returns 0 exit status for most failed connections
To: None <gnats-bugs@NetBSD.ORG>
From: James E. Bernard <jbernard@tater.Mines.EDU>
List: netbsd-bugs
Date: 08/18/1996 08:06:11
>Number:         2705
>Category:       bin
>Synopsis:       pppd returns 0 exit status for most failed connections
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Aug 18 10:20:01 1996
>Originator:     Jim Bernard
	Speaking for myself
>Release:        1.2_BETA
System: NetBSD zoo 1.2_BETA NetBSD 1.2_BETA (ZOO) #0: Sun Aug 18 05:58:18 MDT 1996 local@zoo:/home/local/compile/sys/arch/i386/compile/ZOO i386

	When pppd is run with -detach to keep it attached to the terminal, the
	exit status returned for most failure modes, including a chat-script
	failure is 0.  (Actually, the exit status doesn't depend on the use
	of "-detach".)  Having non-zero exit status in such cases is useful, for
	example, in a wrapper script that retries failed connections a finite
	number of times (in contrast to -persist, which continues forever).
	The pppd supplied in NetBSD 1.1 did correctly return non-zero exit
	status when the chat script failed.
	Add "ABORT RINGING" to chat script (to force rapid failure on an otherwise
	successful dial attempt) and attempt connection via "pppd -detach".  Then
	test exit status and observe that it is zero, in spite of failed chat.
	(Note that chat itself returns non-zero status in this case.)
	The main loop contains a number of "goto fail" jumps in various cases of
	failure, and when the "persist" option is not in effect, the code just
	breaks to the end and executes "die(0)", which does cleanup and exits
	with the specified status (0).  The solution is to replace the break with
*** usr.sbin/pppd/main.c-dist	Fri Mar 22 05:32:20 1996
--- usr.sbin/pppd/main.c	Sat Aug 17 19:12:44 1996
*** 509,515 ****
  	if (!persist)
! 	    break;
  	if (demand)
--- 509,515 ----
  	if (!persist)
! 	    die(1);
  	if (demand)