... | ... |
@@ -45,7 +45,7 @@ export makefile_defs |
45 | 45 |
VERSION = 0 |
46 | 46 |
PATCHLEVEL = 8 |
47 | 47 |
SUBLEVEL = 13 |
48 |
-EXTRAVERSION = -dev-28 |
|
48 |
+EXTRAVERSION = -dev-29 |
|
49 | 49 |
|
50 | 50 |
RELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) |
51 | 51 |
OS = $(shell uname -s | sed -e s/SunOS/solaris/ | tr "[A-Z]" "[a-z]") |
... | ... |
@@ -31,8 +31,12 @@ |
31 | 31 |
* 2004-02-20 removed from ser main.c into its own file (andrei) |
32 | 32 |
* 2004-03-04 moved setuid/setgid in do_suid() (andrei) |
33 | 33 |
* 2004-03-25 added increase_open_fds & set_core_dump (andrei) |
34 |
+ * 2004-04-04 applied pgid patch from janakj |
|
34 | 35 |
*/ |
35 | 36 |
|
37 |
+#define _XOPEN_SOURCE |
|
38 |
+#define _XOPEN_SOURCE_EXTENDED |
|
39 |
+ |
|
36 | 40 |
#include <sys/types.h> |
37 | 41 |
#include <unistd.h> |
38 | 42 |
#include <signal.h> |
... | ... |
@@ -127,6 +131,27 @@ int daemonize(char* name) |
127 | 131 |
fclose(pid_stream); |
128 | 132 |
} |
129 | 133 |
} |
134 |
+ |
|
135 |
+ if (pgid_file!=0){ |
|
136 |
+ if ((pid_stream=fopen(pgid_file, "r"))!=NULL){ |
|
137 |
+ fscanf(pid_stream, "%d", &p); |
|
138 |
+ fclose(pid_stream); |
|
139 |
+ if (p==-1){ |
|
140 |
+ LOG(L_CRIT, "pgid file %s exists, but doesn't contain a valid" |
|
141 |
+ " pgid number\n", pgid_file); |
|
142 |
+ goto error; |
|
143 |
+ } |
|
144 |
+ } |
|
145 |
+ pid=getpgid(0); |
|
146 |
+ if ((pid_stream=fopen(pgid_file, "w"))==NULL){ |
|
147 |
+ LOG(L_WARN, "unable to create pgid file %s: %s\n", |
|
148 |
+ pgid_file, strerror(errno)); |
|
149 |
+ goto error; |
|
150 |
+ }else{ |
|
151 |
+ fprintf(pid_stream, "%i\n", (int)pid); |
|
152 |
+ fclose(pid_stream); |
|
153 |
+ } |
|
154 |
+ } |
|
130 | 155 |
|
131 | 156 |
/* try to replace stdin, stdout & stderr with /dev/null */ |
132 | 157 |
if (freopen("/dev/null", "r", stdin)==0){ |
... | ... |
@@ -51,6 +51,7 @@ extern unsigned short port_no; |
51 | 51 |
extern int uid; |
52 | 52 |
extern int gid; |
53 | 53 |
char* pid_file; |
54 |
+char* pgid_file; |
|
54 | 55 |
extern int own_pgid; /* whether or not we have our own pgid (and it's ok |
55 | 56 |
>--->--->--->--->--->--->--->--->--->--->--- to use kill(0, sig) */ |
56 | 57 |
|
... | ... |
@@ -237,6 +237,7 @@ Options:\n\ |
237 | 237 |
-u uid Change uid \n\ |
238 | 238 |
-g gid Change gid \n\ |
239 | 239 |
-P file Create a pid file\n\ |
240 |
+ -G file Create a pgid file\n\ |
|
240 | 241 |
-i fifo_path Create a fifo (usefull for monitoring " NAME ") \n\ |
241 | 242 |
-x socket Create a unix domain socket \n" |
242 | 243 |
#ifdef STATS |
... | ... |
@@ -405,7 +406,7 @@ extern int yyparse(); |
405 | 406 |
int is_main=1; /* flag = is this the "main" process? */ |
406 | 407 |
|
407 | 408 |
char* pid_file = 0; /* filename as asked by use */ |
408 |
- |
|
409 |
+char* pgid_file = 0; |
|
409 | 410 |
|
410 | 411 |
|
411 | 412 |
/* callit before exiting; if show_status==1, mem status is displayed */ |
... | ... |
@@ -440,6 +441,7 @@ void cleanup(show_status) |
440 | 441 |
shm_mem_destroy(); |
441 | 442 |
#endif |
442 | 443 |
if (pid_file) unlink(pid_file); |
444 |
+ if (pgid_file) unlink(pgid_file); |
|
443 | 445 |
} |
444 | 446 |
|
445 | 447 |
|
... | ... |
@@ -1125,7 +1127,7 @@ int main(int argc, char** argv) |
1125 | 1127 |
#ifdef STATS |
1126 | 1128 |
"s:" |
1127 | 1129 |
#endif |
1128 |
- "f:cp:m:b:l:n:N:rRvdDETVhw:t:u:g:P:i:x:"; |
|
1130 |
+ "f:cp:m:b:l:n:N:rRvdDETVhw:t:u:g:P:G:i:x:"; |
|
1129 | 1131 |
|
1130 | 1132 |
while((c=getopt(argc,argv,options))!=-1){ |
1131 | 1133 |
switch(c){ |
... | ... |
@@ -1248,6 +1250,9 @@ int main(int argc, char** argv) |
1248 | 1250 |
case 'P': |
1249 | 1251 |
pid_file=optarg; |
1250 | 1252 |
break; |
1253 |
+ case 'G': |
|
1254 |
+ pgid_file=optarg; |
|
1255 |
+ break; |
|
1251 | 1256 |
case 'i': |
1252 | 1257 |
fifo=optarg; |
1253 | 1258 |
break; |