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