Fossil SCM
A simpler method of ensuring that backoffice does not cling to the standard input and output.
Commit
8c52c6741283f61f78cfa3a6587f1328c1ad80b061b0ba8bed7b4f03e410ebe4
Parent
6865fb72cf5c8ac…
3 files changed
+2
-4
-1
-13
+2
-4
| --- src/backoffice.c | ||
| +++ src/backoffice.c | ||
| @@ -709,13 +709,11 @@ | ||
| 709 | 709 | GETPID(), GetProcessId((HANDLE)x)); |
| 710 | 710 | if( x>=0 ) return; |
| 711 | 711 | } |
| 712 | 712 | #else /* unix */ |
| 713 | 713 | { |
| 714 | - pid_t pid; | |
| 715 | - if( g.fdDevNull<0 ) return; | |
| 716 | - pid = fork(); | |
| 714 | + pid_t pid = fork(); | |
| 717 | 715 | if( pid>0 ){ |
| 718 | 716 | /* This is the parent in a successful fork(). Return immediately. */ |
| 719 | 717 | backofficeTrace( |
| 720 | 718 | "/***** Subprocess %d creates backoffice child %d *****/\n", |
| 721 | 719 | GETPID(), (int)pid); |
| @@ -725,11 +723,11 @@ | ||
| 725 | 723 | /* This is the child of a successful fork(). Run backoffice. */ |
| 726 | 724 | int i; |
| 727 | 725 | setsid(); |
| 728 | 726 | for(i=0; i<=2; i++){ |
| 729 | 727 | close(i); |
| 730 | - dup(g.fdDevNull); | |
| 728 | + open("/dev/null", O_RDWR); | |
| 731 | 729 | } |
| 732 | 730 | for(i=3; i<100; i++){ close(i); } |
| 733 | 731 | db_open_repository(backofficeDb); |
| 734 | 732 | backofficeDb = "x"; |
| 735 | 733 | backoffice_thread(); |
| 736 | 734 |
| --- src/backoffice.c | |
| +++ src/backoffice.c | |
| @@ -709,13 +709,11 @@ | |
| 709 | GETPID(), GetProcessId((HANDLE)x)); |
| 710 | if( x>=0 ) return; |
| 711 | } |
| 712 | #else /* unix */ |
| 713 | { |
| 714 | pid_t pid; |
| 715 | if( g.fdDevNull<0 ) return; |
| 716 | pid = fork(); |
| 717 | if( pid>0 ){ |
| 718 | /* This is the parent in a successful fork(). Return immediately. */ |
| 719 | backofficeTrace( |
| 720 | "/***** Subprocess %d creates backoffice child %d *****/\n", |
| 721 | GETPID(), (int)pid); |
| @@ -725,11 +723,11 @@ | |
| 725 | /* This is the child of a successful fork(). Run backoffice. */ |
| 726 | int i; |
| 727 | setsid(); |
| 728 | for(i=0; i<=2; i++){ |
| 729 | close(i); |
| 730 | dup(g.fdDevNull); |
| 731 | } |
| 732 | for(i=3; i<100; i++){ close(i); } |
| 733 | db_open_repository(backofficeDb); |
| 734 | backofficeDb = "x"; |
| 735 | backoffice_thread(); |
| 736 |
| --- src/backoffice.c | |
| +++ src/backoffice.c | |
| @@ -709,13 +709,11 @@ | |
| 709 | GETPID(), GetProcessId((HANDLE)x)); |
| 710 | if( x>=0 ) return; |
| 711 | } |
| 712 | #else /* unix */ |
| 713 | { |
| 714 | pid_t pid = fork(); |
| 715 | if( pid>0 ){ |
| 716 | /* This is the parent in a successful fork(). Return immediately. */ |
| 717 | backofficeTrace( |
| 718 | "/***** Subprocess %d creates backoffice child %d *****/\n", |
| 719 | GETPID(), (int)pid); |
| @@ -725,11 +723,11 @@ | |
| 723 | /* This is the child of a successful fork(). Run backoffice. */ |
| 724 | int i; |
| 725 | setsid(); |
| 726 | for(i=0; i<=2; i++){ |
| 727 | close(i); |
| 728 | open("/dev/null", O_RDWR); |
| 729 | } |
| 730 | for(i=3; i<100; i++){ close(i); } |
| 731 | db_open_repository(backofficeDb); |
| 732 | backofficeDb = "x"; |
| 733 | backoffice_thread(); |
| 734 |
-1
| --- src/main.c | ||
| +++ src/main.c | ||
| @@ -133,11 +133,10 @@ | ||
| 133 | 133 | int argc; char **argv; /* Command-line arguments to the program */ |
| 134 | 134 | char *nameOfExe; /* Full path of executable. */ |
| 135 | 135 | const char *zErrlog; /* Log errors to this file, if not NULL */ |
| 136 | 136 | int isConst; /* True if the output is unchanging & cacheable */ |
| 137 | 137 | const char *zVfsName; /* The VFS to use for database connections */ |
| 138 | - int fdDevNull; /* /dev/null file descriptor */ | |
| 139 | 138 | sqlite3 *db; /* The connection to the databases */ |
| 140 | 139 | sqlite3 *dbConfig; /* Separate connection for global_config table */ |
| 141 | 140 | char *zAuxSchema; /* Main repository aux-schema */ |
| 142 | 141 | int dbIgnoreErrors; /* Ignore database errors if true */ |
| 143 | 142 | const char *zConfigDbName;/* Path of the config database. NULL if not open */ |
| 144 | 143 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -133,11 +133,10 @@ | |
| 133 | int argc; char **argv; /* Command-line arguments to the program */ |
| 134 | char *nameOfExe; /* Full path of executable. */ |
| 135 | const char *zErrlog; /* Log errors to this file, if not NULL */ |
| 136 | int isConst; /* True if the output is unchanging & cacheable */ |
| 137 | const char *zVfsName; /* The VFS to use for database connections */ |
| 138 | int fdDevNull; /* /dev/null file descriptor */ |
| 139 | sqlite3 *db; /* The connection to the databases */ |
| 140 | sqlite3 *dbConfig; /* Separate connection for global_config table */ |
| 141 | char *zAuxSchema; /* Main repository aux-schema */ |
| 142 | int dbIgnoreErrors; /* Ignore database errors if true */ |
| 143 | const char *zConfigDbName;/* Path of the config database. NULL if not open */ |
| 144 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -133,11 +133,10 @@ | |
| 133 | int argc; char **argv; /* Command-line arguments to the program */ |
| 134 | char *nameOfExe; /* Full path of executable. */ |
| 135 | const char *zErrlog; /* Log errors to this file, if not NULL */ |
| 136 | int isConst; /* True if the output is unchanging & cacheable */ |
| 137 | const char *zVfsName; /* The VFS to use for database connections */ |
| 138 | sqlite3 *db; /* The connection to the databases */ |
| 139 | sqlite3 *dbConfig; /* Separate connection for global_config table */ |
| 140 | char *zAuxSchema; /* Main repository aux-schema */ |
| 141 | int dbIgnoreErrors; /* Ignore database errors if true */ |
| 142 | const char *zConfigDbName;/* Path of the config database. NULL if not open */ |
| 143 |
-13
| --- src/style.c | ||
| +++ src/style.c | ||
| @@ -19,16 +19,10 @@ | ||
| 19 | 19 | ** |
| 20 | 20 | */ |
| 21 | 21 | #include "VERSION.h" |
| 22 | 22 | #include "config.h" |
| 23 | 23 | #include "style.h" |
| 24 | -#ifndef _WIN32 | |
| 25 | -# include <sys/types.h> | |
| 26 | -# include <sys/stat.h> | |
| 27 | -# include <fcntl.h># | |
| 28 | -#endif | |
| 29 | - | |
| 30 | 24 | |
| 31 | 25 | /* |
| 32 | 26 | ** Elements of the submenu are collected into the following |
| 33 | 27 | ** structure and displayed below the main menu. |
| 34 | 28 | ** |
| @@ -443,17 +437,10 @@ | ||
| 443 | 437 | if( g.perm.Debug && P("showqp") ){ |
| 444 | 438 | @ <div class="debug"> |
| 445 | 439 | cgi_print_all(0, 0); |
| 446 | 440 | @ </div> |
| 447 | 441 | } |
| 448 | -#ifndef _WIN32 | |
| 449 | - g.fdDevNull = open("/dev/null", O_RDWR); | |
| 450 | - if( g.fdDevNull<0 ){ | |
| 451 | - fossil_warning("cannot open /dev/null"); | |
| 452 | - webpage_error("Cannot open /dev/null"); | |
| 453 | - } | |
| 454 | -#endif | |
| 455 | 442 | } |
| 456 | 443 | |
| 457 | 444 | #if INTERFACE |
| 458 | 445 | /* Allowed parameters for style_adunit() */ |
| 459 | 446 | #define ADUNIT_OFF 0x0001 /* Do not allow ads on this page */ |
| 460 | 447 |
| --- src/style.c | |
| +++ src/style.c | |
| @@ -19,16 +19,10 @@ | |
| 19 | ** |
| 20 | */ |
| 21 | #include "VERSION.h" |
| 22 | #include "config.h" |
| 23 | #include "style.h" |
| 24 | #ifndef _WIN32 |
| 25 | # include <sys/types.h> |
| 26 | # include <sys/stat.h> |
| 27 | # include <fcntl.h># |
| 28 | #endif |
| 29 | |
| 30 | |
| 31 | /* |
| 32 | ** Elements of the submenu are collected into the following |
| 33 | ** structure and displayed below the main menu. |
| 34 | ** |
| @@ -443,17 +437,10 @@ | |
| 443 | if( g.perm.Debug && P("showqp") ){ |
| 444 | @ <div class="debug"> |
| 445 | cgi_print_all(0, 0); |
| 446 | @ </div> |
| 447 | } |
| 448 | #ifndef _WIN32 |
| 449 | g.fdDevNull = open("/dev/null", O_RDWR); |
| 450 | if( g.fdDevNull<0 ){ |
| 451 | fossil_warning("cannot open /dev/null"); |
| 452 | webpage_error("Cannot open /dev/null"); |
| 453 | } |
| 454 | #endif |
| 455 | } |
| 456 | |
| 457 | #if INTERFACE |
| 458 | /* Allowed parameters for style_adunit() */ |
| 459 | #define ADUNIT_OFF 0x0001 /* Do not allow ads on this page */ |
| 460 |
| --- src/style.c | |
| +++ src/style.c | |
| @@ -19,16 +19,10 @@ | |
| 19 | ** |
| 20 | */ |
| 21 | #include "VERSION.h" |
| 22 | #include "config.h" |
| 23 | #include "style.h" |
| 24 | |
| 25 | /* |
| 26 | ** Elements of the submenu are collected into the following |
| 27 | ** structure and displayed below the main menu. |
| 28 | ** |
| @@ -443,17 +437,10 @@ | |
| 437 | if( g.perm.Debug && P("showqp") ){ |
| 438 | @ <div class="debug"> |
| 439 | cgi_print_all(0, 0); |
| 440 | @ </div> |
| 441 | } |
| 442 | } |
| 443 | |
| 444 | #if INTERFACE |
| 445 | /* Allowed parameters for style_adunit() */ |
| 446 | #define ADUNIT_OFF 0x0001 /* Do not allow ads on this page */ |
| 447 |