Browse code

- make install - exit on SIGCHLD even if in a child - hack for nofork is_main & init_child

Andrei Pelinescu-Onciul authored on 12/07/2002 16:13:58
Showing 3 changed files
... ...
@@ -10,7 +10,7 @@ auto_gen=lex.yy.c cfg.tab.c   #lexx, yacc etc
10 10
 #include  source related defs
11 11
 include Makefile.sources
12 12
 
13
-exclude_modules=CVS mysql auth cpl jabber acc pike ext 
13
+exclude_modules=CVS mysql pike
14 14
 static_modules=
15 15
 static_modules_path=$(addprefix modules/, $(static_modules))
16 16
 extra_sources=$(wildcard $(addsuffix /*.c, $(static_modules_path)))
... ...
@@ -22,6 +22,8 @@ DEFS+=$(static_defs)
22 22
 modules=$(filter-out $(addprefix modules/, \
23 23
 			$(exclude_modules) $(static_modules)), \
24 24
 			$(wildcard modules/*))
25
+modules_names=$(patsubst modules/%/, %.so, $(modules))
26
+modules_full_path=$(join $(modules), $(modules_names))
25 27
 
26 28
 NAME=ser
27 29
 
... ...
@@ -84,3 +86,43 @@ tar: mantainer-clean
84 84
 	tar -C .. -zcf ../$(NAME)-$(RELEASE)_src.tar.gz  $(notdir $(CURDIR)) 
85 85
 
86 86
 
87
+install: all mk-install-dirs install-cfg install-bin install-modules \
88
+	install-doc
89
+
90
+
91
+mk-install-dirs: $(cfg-prefix)/$(cfg-dir) $(bin-prefix)/$(bin-dir) \
92
+			$(modules-prefix)/$(modules-dir) $(doc-prefix)/$(doc-dir)
93
+
94
+$(cfg-prefix)/$(cfg-dir): 
95
+		mkdir -p $(cfg-prefix)/$(cfg-dir)
96
+
97
+$(bin-prefix)/$(bin-dir):
98
+		mkdir -p $(bin-prefix)/$(bin-dir)
99
+
100
+$(modules-prefix)/$(modules-dir):
101
+		mkdir -p $(modules-prefix)/$(modules-dir)
102
+
103
+
104
+$(doc-prefix)/$(doc-dir):
105
+		mkdir -p $(doc-prefix)/$(doc-dir)
106
+
107
+
108
+install-cfg:
109
+		$(INSTALL-CFG) ser.cfg $(cfg-prefix)/$(cfg-dir)
110
+
111
+install-bin:
112
+		$(INSTALL-BIN) ser $(bin-prefix)/$(bin-dir)
113
+
114
+
115
+install-modules:
116
+	-@for r in $(modules_full_path) "" ; do \
117
+		if [ -n "$$r" ]; then \
118
+			$(INSTALL-MODULES)  $$r  $(modules-prefix)/$(modules-dir) ; \
119
+		fi ; \
120
+	done 
121
+
122
+
123
+install-doc:
124
+	$(INSTALL-DOC) README $(doc-prefix)/$(doc-dir)
125
+
126
+
... ...
@@ -8,12 +8,31 @@
8 8
 VERSION = 0
9 9
 PATCHLEVEL = 8
10 10
 SUBLEVEL = 7
11
-EXTRAVERSION = -5-ipv6
11
+EXTRAVERSION = -6-ipv6
12 12
 
13 13
 RELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
14 14
 OS = $(shell uname -s)
15 15
 ARCH = $(shell uname -m |sed -e s/i.86/i386/ -e s/sun4u/sparc64/ )
16 16
 
17
+prefix = /usr/local
18
+cfg-prefix = $(prefix)
19
+bin-prefix = $(prefix)
20
+modules-prefix= $(prefix)
21
+doc-prefix = $(prefix)
22
+
23
+# dirs
24
+cfg-dir = etc/ser/
25
+bin-dir = sbin/
26
+modules-dir = lib/ser/modules/
27
+doc-dir = doc/ser/
28
+
29
+INSTALL = install -b
30
+INSTALL-CFG = $(INSTALL) -m 644
31
+INSTALL-BIN = $(INSTALL) -m 755
32
+INSTALL-MODULES = $(INSTALL) -m 755
33
+INSTALL-DOC = $(INSTALL) -m 644
34
+
35
+
17 36
 # compile-time options
18 37
 #
19 38
 # -DSTATS
... ...
@@ -484,7 +484,6 @@ int main_loop()
484 484
 				}
485 485
 		}
486 486
 		/* main process, receive loop */
487
-		is_main=1;
488 487
 		pids[0]=getpid();
489 488
 		process_bit = 1;
490 489
 		process_no=0; /*main process number*/
... ...
@@ -497,6 +496,8 @@ int main_loop()
497 497
 			LOG(L_ERR, "init_child failed\n");
498 498
 			goto error;
499 499
 		}
500
+		is_main=1; /* hack 42: call init_child with is_main=0 in case
501
+					 some modules wants to fork a child */
500 502
 		
501 503
 		return udp_rcv_loop();
502 504
 	}else{
... ...
@@ -593,7 +594,7 @@ static void sig_usr(int signo)
593 593
 		else /*  previous sig. not processed yet, ignoring? */
594 594
 			return; ;
595 595
 		if (dont_fork) 
596
-				/* only one proc, dooing everything from the sig handler,
596
+				/* only one proc, doing everything from the sig handler,
597 597
 				unsafe, but this is only for debugging mode*/
598 598
 			handle_sigs();
599 599
 	}else{
... ...
@@ -611,6 +612,8 @@ static void sig_usr(int signo)
611 611
 			case SIGUSR2:
612 612
 			case SIGHUP:
613 613
 					break;
614
+			case SIGCHLD:
615
+					exit(0); /* terminate if one child died */
614 616
 		}
615 617
 	}
616 618
 }