clean_exit.c revision 1.1
11.1Smrg /*
21.1Smrg  * clean_exit() cleans up and terminates the program. It should be called
31.1Smrg  * instead of exit() when for some reason the real network daemon will not or
41.1Smrg  * cannot be run. Reason: in the case of a datagram-oriented service we must
51.1Smrg  * discard the not-yet received data from the client. Otherwise, inetd will
61.1Smrg  * see the same datagram again and again, and go into a loop.
71.1Smrg  *
81.1Smrg  * Author: Wietse Venema, Eindhoven University of Technology, The Netherlands.
91.1Smrg  */
101.1Smrg
111.1Smrg#ifndef lint
121.1Smrgstatic char sccsid[] = "@(#) clean_exit.c 1.4 94/12/28 17:42:19";
131.1Smrg#endif
141.1Smrg
151.1Smrg#include <stdio.h>
161.1Smrg
171.1Smrgextern void exit();
181.1Smrg
191.1Smrg#include "tcpd.h"
201.1Smrg
211.1Smrg/* clean_exit - clean up and exit */
221.1Smrg
231.1Smrgvoid    clean_exit(request)
241.1Smrgstruct request_info *request;
251.1Smrg{
261.1Smrg
271.1Smrg    /*
281.1Smrg     * In case of unconnected protocols we must eat up the not-yet received
291.1Smrg     * data or inetd will loop.
301.1Smrg     */
311.1Smrg
321.1Smrg    if (request->sink)
331.1Smrg	request->sink(request->fd);
341.1Smrg
351.1Smrg    /*
361.1Smrg     * Be kind to the inetd. We already reported the problem via the syslogd,
371.1Smrg     * and there is no need for additional garbage in the logfile.
381.1Smrg     */
391.1Smrg
401.1Smrg    sleep(5);
411.1Smrg    exit(0);
421.1Smrg}
43