1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 3*0Sstevel@tonic-gate * Use is subject to license terms. 4*0Sstevel@tonic-gate */ 5*0Sstevel@tonic-gate 6*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 7*0Sstevel@tonic-gate 8*0Sstevel@tonic-gate /* 9*0Sstevel@tonic-gate * clean_exit() cleans up and terminates the program. It should be called 10*0Sstevel@tonic-gate * instead of exit() when for some reason the real network daemon will not or 11*0Sstevel@tonic-gate * cannot be run. Reason: in the case of a datagram-oriented service we must 12*0Sstevel@tonic-gate * discard the not-yet received data from the client. Otherwise, inetd will 13*0Sstevel@tonic-gate * see the same datagram again and again, and go into a loop. 14*0Sstevel@tonic-gate * 15*0Sstevel@tonic-gate * Author: Wietse Venema, Eindhoven University of Technology, The Netherlands. 16*0Sstevel@tonic-gate */ 17*0Sstevel@tonic-gate 18*0Sstevel@tonic-gate #ifndef lint 19*0Sstevel@tonic-gate static char sccsid[] = "@(#) clean_exit.c 1.4 94/12/28 17:42:19"; 20*0Sstevel@tonic-gate #endif 21*0Sstevel@tonic-gate 22*0Sstevel@tonic-gate #include <stdio.h> 23*0Sstevel@tonic-gate #include <stdlib.h> 24*0Sstevel@tonic-gate #include <unistd.h> 25*0Sstevel@tonic-gate 26*0Sstevel@tonic-gate extern void exit(); 27*0Sstevel@tonic-gate 28*0Sstevel@tonic-gate #include "tcpd.h" 29*0Sstevel@tonic-gate 30*0Sstevel@tonic-gate /* clean_exit - clean up and exit */ 31*0Sstevel@tonic-gate 32*0Sstevel@tonic-gate void clean_exit(request) 33*0Sstevel@tonic-gate struct request_info *request; 34*0Sstevel@tonic-gate { 35*0Sstevel@tonic-gate 36*0Sstevel@tonic-gate /* 37*0Sstevel@tonic-gate * In case of unconnected protocols we must eat up the not-yet received 38*0Sstevel@tonic-gate * data or inetd will loop. 39*0Sstevel@tonic-gate */ 40*0Sstevel@tonic-gate 41*0Sstevel@tonic-gate if (request->sink) 42*0Sstevel@tonic-gate request->sink(request->fd); 43*0Sstevel@tonic-gate 44*0Sstevel@tonic-gate /* 45*0Sstevel@tonic-gate * Be kind to the inetd. We already reported the problem via the syslogd, 46*0Sstevel@tonic-gate * and there is no need for additional garbage in the logfile. 47*0Sstevel@tonic-gate */ 48*0Sstevel@tonic-gate 49*0Sstevel@tonic-gate sleep(5); 50*0Sstevel@tonic-gate exit(0); 51*0Sstevel@tonic-gate } 52