httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From di...@covalent.net
Subject Deamon tools
Date Mon, 13 May 2002 21:45:12 GMT

Hmm - not entirely trivial; it turns out that most unix-es do not take
kindly to

	setsid()

when not detached/non-root. So I changed Jos/Michaels patch. See below.
Anyone any comments ?

Dw

Index: CHANGES
===================================================================
RCS file: /home/cvs/apache-1.3/src/CHANGES,v
retrieving revision 1.1817
diff -r1.1817 CHANGES
2a3,8
>   *) Added a '-F' flag; which causes the mother/supervisor process to
>      no longer fork down and detach. But instead stays attached to
>      the tty - thus making live for automatic restart and exit checking
>      code easier. [ Contributed by Michael Handler <handler@grendel.net>,
>      Jos Backus <jos@catnook.com> [ Dirk-Willem van Gulik ]].
>
Index: main/http_main.c
===================================================================
RCS file: /home/cvs/apache-1.3/src/main/http_main.c,v
retrieving revision 1.580
diff -r1.580 http_main.c
343a344,345
> static int do_detach = 1;
>
1352c1354
<     fprintf(stderr, "       %s [-v] [-V] [-h] [-l] [-L] [-S] [-t] [-T]\n", pad);
---
>     fprintf(stderr, "       %s [-v] [-V] [-h] [-l] [-L] [-S] [-t] [-T] [-F]\n", pad);
1360c1362
<     fprintf(stderr, "       %s [-v] [-V] [-h] [-l] [-L] [-S] [-t] [-T]\n", pad);
---
>     fprintf(stderr, "       %s [-v] [-V] [-h] [-l] [-L] [-S] [-t] [-T] [-F]\n", pad);
1382a1385
>     fprintf(stderr, "  -F               : run main process in foreground, for process
supervisors\n");
3377,3382c3380,3388
<     if ((x = fork()) > 0)
< 	exit(0);
<     else if (x == -1) {
< 	perror("fork");
< 	fprintf(stderr, "%s: unable to fork new process\n", ap_server_argv0);
< 	exit(1);
---
>     if (do_detach) {
>         if ((x = fork()) > 0)
>             exit(0);
>         else if (x == -1) {
>             perror("fork");
> 	    fprintf(stderr, "%s: unable to fork new process\n", ap_server_argv0);
> 	    exit(1);
>         }
>         RAISE_SIGSTOP(DETACH);
3384d3389
<     RAISE_SIGSTOP(DETACH);
3387c3392
<     if ((pgrp = setsid()) == -1) {
---
>     if ((do_detach) && ((pgrp = setsid()) == -1)) {
5315c5320
< 				    "D:C:c:xXd:f:vVlLR:StTh"
---
> 				    "D:C:c:xXd:Ff:vVlLR:StTh"
5336a5342,5344
> 	case 'F':
> 	    do_detach = 0;
> 	    break;
7218c7226
<     while ((c = getopt(argc, argv, "D:C:c:Xd:f:vVlLz:Z:wiuStThk:n:W:")) != -1) {
---
>     while ((c = getopt(argc, argv, "D:C:c:Xd:fF:vVlLz:Z:wiuStThk:n:W:")) != -1) {
7220c7228
<     while ((c = getopt(argc, argv, "D:C:c:Xd:f:vVlLesStTh")) != -1) {
---
>     while ((c = getopt(argc, argv, "D:C:c:Xd:fF:vVlLesStTh")) != -1) {
7341a7350,7352
> 	case 'F':
> 	    do_detach = 0;
> 	    break;
7736c7747
<     while ((c = getopt(argc, argv, "D:C:c:Xd:f:vVlLR:SZ:tTh")) != -1) {
---
>     while ((c = getopt(argc, argv, "D:C:c:Xd:Ff:vVlLR:SZ:tTh")) != -1) {
7742a7754
> 	case 'F':


-- 
Dirk-Willem van Gulik


Mime
View raw message