Rename foreground to background and change logic accordingly

This commit is contained in:
Julien BLACHE 2009-05-05 17:54:20 +02:00
parent 10bb9dec57
commit 803ca7e59f
1 changed files with 7 additions and 7 deletions

View File

@ -145,7 +145,7 @@ void usage(char *program) {
static int static int
daemonize(int foreground, char *runas, char *pidfile) daemonize(int background, char *runas, char *pidfile)
{ {
FILE *fp; FILE *fp;
int fd; int fd;
@ -168,7 +168,7 @@ daemonize(int foreground, char *runas, char *pidfile)
else else
pw = NULL; pw = NULL;
if (!foreground) if (background)
{ {
fp = fopen(pidfile, "w"); fp = fopen(pidfile, "w");
if (!fp) if (!fp)
@ -330,7 +330,7 @@ int main(int argc, char *argv[]) {
int option; int option;
char *configfile=CONFFILE; char *configfile=CONFFILE;
int reload=0; int reload=0;
int foreground; int background;
int force_non_root=0; int force_non_root=0;
int skip_initial=1; int skip_initial=1;
cfg_t *lib; cfg_t *lib;
@ -353,7 +353,7 @@ int main(int argc, char *argv[]) {
err_setlevel(2); err_setlevel(2);
foreground = 0; background = 1;
while((option=getopt(argc,argv,"D:d:c:P:frysiub:v")) != -1) { while((option=getopt(argc,argv,"D:d:c:P:frysiub:v")) != -1) {
switch(option) { switch(option) {
@ -374,7 +374,7 @@ int main(int argc, char *argv[]) {
break; break;
case 'f': case 'f':
foreground = 1; background = 0;
err_setdest(err_getdest() | LOGDEST_STDERR); err_setdest(err_getdest() | LOGDEST_STDERR);
break; break;
@ -451,7 +451,7 @@ int main(int argc, char *argv[]) {
/* Daemonize and drop privileges */ /* Daemonize and drop privileges */
runas = cfg_getstr(cfg_getsec(cfg, "general"), "uid"); runas = cfg_getstr(cfg_getsec(cfg, "general"), "uid");
ret = daemonize(foreground, runas, pidfile); ret = daemonize(background, runas, pidfile);
if (ret < 0) if (ret < 0)
{ {
DPRINTF(E_LOG, L_MAIN, "Could not initialize server\n"); DPRINTF(E_LOG, L_MAIN, "Could not initialize server\n");
@ -601,7 +601,7 @@ int main(int argc, char *argv[]) {
DPRINTF(E_LOG,L_MAIN|L_DB,"Closing database\n"); DPRINTF(E_LOG,L_MAIN|L_DB,"Closing database\n");
db_deinit(); db_deinit();
if (!foreground) if (background)
{ {
ret = unlink(pidfile); ret = unlink(pidfile);
if (ret < 0) if (ret < 0)