Fossil SCM

A simpler method of ensuring that backoffice does not cling to the standard input and output.

drh 2018-08-08 18:10 UTC backoffice-full-close
Commit 8c52c6741283f61f78cfa3a6587f1328c1ad80b061b0ba8bed7b4f03e410ebe4
--- src/backoffice.c
+++ src/backoffice.c
@@ -709,13 +709,11 @@
709709
GETPID(), GetProcessId((HANDLE)x));
710710
if( x>=0 ) return;
711711
}
712712
#else /* unix */
713713
{
714
- pid_t pid;
715
- if( g.fdDevNull<0 ) return;
716
- pid = fork();
714
+ pid_t pid = fork();
717715
if( pid>0 ){
718716
/* This is the parent in a successful fork(). Return immediately. */
719717
backofficeTrace(
720718
"/***** Subprocess %d creates backoffice child %d *****/\n",
721719
GETPID(), (int)pid);
@@ -725,11 +723,11 @@
725723
/* This is the child of a successful fork(). Run backoffice. */
726724
int i;
727725
setsid();
728726
for(i=0; i<=2; i++){
729727
close(i);
730
- dup(g.fdDevNull);
728
+ open("/dev/null", O_RDWR);
731729
}
732730
for(i=3; i<100; i++){ close(i); }
733731
db_open_repository(backofficeDb);
734732
backofficeDb = "x";
735733
backoffice_thread();
736734
--- 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 @@
133133
int argc; char **argv; /* Command-line arguments to the program */
134134
char *nameOfExe; /* Full path of executable. */
135135
const char *zErrlog; /* Log errors to this file, if not NULL */
136136
int isConst; /* True if the output is unchanging & cacheable */
137137
const char *zVfsName; /* The VFS to use for database connections */
138
- int fdDevNull; /* /dev/null file descriptor */
139138
sqlite3 *db; /* The connection to the databases */
140139
sqlite3 *dbConfig; /* Separate connection for global_config table */
141140
char *zAuxSchema; /* Main repository aux-schema */
142141
int dbIgnoreErrors; /* Ignore database errors if true */
143142
const char *zConfigDbName;/* Path of the config database. NULL if not open */
144143
--- 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 @@
1919
**
2020
*/
2121
#include "VERSION.h"
2222
#include "config.h"
2323
#include "style.h"
24
-#ifndef _WIN32
25
-# include <sys/types.h>
26
-# include <sys/stat.h>
27
-# include <fcntl.h>#
28
-#endif
29
-
3024
3125
/*
3226
** Elements of the submenu are collected into the following
3327
** structure and displayed below the main menu.
3428
**
@@ -443,17 +437,10 @@
443437
if( g.perm.Debug && P("showqp") ){
444438
@ <div class="debug">
445439
cgi_print_all(0, 0);
446440
@ </div>
447441
}
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
455442
}
456443
457444
#if INTERFACE
458445
/* Allowed parameters for style_adunit() */
459446
#define ADUNIT_OFF 0x0001 /* Do not allow ads on this page */
460447
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button