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