1 /*
2  * This file is part of DGD, https://github.com/dworkin/dgd
3  * Copyright (C) 1993-2010 Dworkin B.V.
4  * Copyright (C) 2010-2011 DGD Authors (see the commit log for details)
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Affero General Public License as
8  * published by the Free Software Foundation, either version 3 of the
9  * License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU Affero General Public License for more details.
15  *
16  * You should have received a copy of the GNU Affero General Public License
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 # include "dgd.h"
21 # include <signal.h>
22 
23 /*
24  * NAME:	term()
25  * DESCRIPTION:	catch SIGTERM
26  */
term()27 static void term()
28 {
29     signal(SIGTERM, term);
30     interrupt();
31 }
32 
33 /*
34  * NAME:	main()
35  * DESCRIPTION:	main program
36  */
main(int argc,char * argv[])37 int main(int argc, char *argv[])
38 {
39     long seed;
40     unsigned short mtime;
41 
42     seed = P_mtime(&mtime);
43     P_srandom(seed ^ ((long) mtime << 22));
44     signal(SIGPIPE, SIG_IGN);
45     signal(SIGTERM, term);
46     return dgd_main(argc, argv);
47 }
48 
49 /*
50  * NAME:	P->message()
51  * DESCRIPTION:	show message
52  */
P_message(char * mess)53 void P_message(char *mess)
54 {
55     fputs(mess, stderr);
56     fflush(stderr);
57 }
58