xref: /freebsd-src/contrib/tcp_wrappers/clean_exit.c (revision 14f102eacc8434a5a1f96466752578a4167140c9)
12aef6930SMark Murray  /*
22aef6930SMark Murray   * clean_exit() cleans up and terminates the program. It should be called
32aef6930SMark Murray   * instead of exit() when for some reason the real network daemon will not or
42aef6930SMark Murray   * cannot be run. Reason: in the case of a datagram-oriented service we must
52aef6930SMark Murray   * discard the not-yet received data from the client. Otherwise, inetd will
62aef6930SMark Murray   * see the same datagram again and again, and go into a loop.
72aef6930SMark Murray   *
82aef6930SMark Murray   * Author: Wietse Venema, Eindhoven University of Technology, The Netherlands.
92aef6930SMark Murray   */
102aef6930SMark Murray 
112aef6930SMark Murray #ifndef lint
122aef6930SMark Murray static char sccsid[] = "@(#) clean_exit.c 1.4 94/12/28 17:42:19";
132aef6930SMark Murray #endif
142aef6930SMark Murray 
152aef6930SMark Murray #include <stdio.h>
1646bcf11dSSean Bruno #include <unistd.h>
172aef6930SMark Murray 
182aef6930SMark Murray extern void exit();
192aef6930SMark Murray 
202aef6930SMark Murray #include "tcpd.h"
212aef6930SMark Murray 
222aef6930SMark Murray /* clean_exit - clean up and exit */
232aef6930SMark Murray 
clean_exit(struct request_info * request)24*14f102eaSEd Maste void    clean_exit(struct request_info *request)
252aef6930SMark Murray {
262aef6930SMark Murray 
272aef6930SMark Murray     /*
282aef6930SMark Murray      * In case of unconnected protocols we must eat up the not-yet received
292aef6930SMark Murray      * data or inetd will loop.
302aef6930SMark Murray      */
312aef6930SMark Murray 
322aef6930SMark Murray     if (request->sink)
332aef6930SMark Murray 	request->sink(request->fd);
342aef6930SMark Murray 
352aef6930SMark Murray     /*
362aef6930SMark Murray      * Be kind to the inetd. We already reported the problem via the syslogd,
372aef6930SMark Murray      * and there is no need for additional garbage in the logfile.
382aef6930SMark Murray      */
392aef6930SMark Murray 
402aef6930SMark Murray     sleep(5);
412aef6930SMark Murray     exit(0);
422aef6930SMark Murray }
43