Merge 2edfc38b8e
into d97d486d53
This commit is contained in:
commit
d112929aa6
@ -121,6 +121,7 @@ LogLevel Info
|
|||||||
#
|
#
|
||||||
# PidFile: Write the PID of the main tinyproxy thread to this file so it
|
# PidFile: Write the PID of the main tinyproxy thread to this file so it
|
||||||
# can be used for signalling purposes.
|
# can be used for signalling purposes.
|
||||||
|
# If not specified, no pidfile will be written.
|
||||||
#
|
#
|
||||||
#PidFile "@localstatedir@/run/tinyproxy/tinyproxy.pid"
|
#PidFile "@localstatedir@/run/tinyproxy/tinyproxy.pid"
|
||||||
|
|
||||||
|
@ -70,7 +70,10 @@ static unsigned int logging_initialized = FALSE; /* boolean */
|
|||||||
*/
|
*/
|
||||||
int open_log_file (const char *log_file_name)
|
int open_log_file (const char *log_file_name)
|
||||||
{
|
{
|
||||||
log_file_fd = create_file_safely (log_file_name, FALSE);
|
if (config.godaemon == FALSE)
|
||||||
|
log_file_fd = fileno(stdout);
|
||||||
|
else
|
||||||
|
log_file_fd = create_file_safely (log_file_name, FALSE);
|
||||||
return log_file_fd;
|
return log_file_fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,7 +82,7 @@ int open_log_file (const char *log_file_name)
|
|||||||
*/
|
*/
|
||||||
void close_log_file (void)
|
void close_log_file (void)
|
||||||
{
|
{
|
||||||
if (log_file_fd < 0) {
|
if (log_file_fd < 0 || log_file_fd == fileno(stdout)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,7 +147,7 @@ display_usage (void)
|
|||||||
printf ("Usage: %s [options]\n", PACKAGE);
|
printf ("Usage: %s [options]\n", PACKAGE);
|
||||||
printf ("\n"
|
printf ("\n"
|
||||||
"Options are:\n"
|
"Options are:\n"
|
||||||
" -d Do not daemonize (run in foreground).\n"
|
" -d Do not daemonize (run in foreground, log to stdout).\n"
|
||||||
" -c FILE Use an alternate configuration file.\n"
|
" -c FILE Use an alternate configuration file.\n"
|
||||||
" -h Display this usage information.\n"
|
" -h Display this usage information.\n"
|
||||||
" -l Display the license.\n"
|
" -l Display the license.\n"
|
||||||
@ -356,7 +356,7 @@ static void initialize_config_defaults (struct config_s *conf)
|
|||||||
conf->stathost = safestrdup (TINYPROXY_STATHOST);
|
conf->stathost = safestrdup (TINYPROXY_STATHOST);
|
||||||
conf->idletimeout = MAX_IDLE_TIME;
|
conf->idletimeout = MAX_IDLE_TIME;
|
||||||
conf->logf_name = safestrdup (LOCALSTATEDIR "/log/tinyproxy/tinyproxy.log");
|
conf->logf_name = safestrdup (LOCALSTATEDIR "/log/tinyproxy/tinyproxy.log");
|
||||||
conf->pidpath = safestrdup (LOCALSTATEDIR "/run/tinyproxy/tinyproxy.pid");
|
conf->pidpath = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -496,7 +496,7 @@ main (int argc, char **argv)
|
|||||||
child_close_sock ();
|
child_close_sock ();
|
||||||
|
|
||||||
/* Remove the PID file */
|
/* Remove the PID file */
|
||||||
if (unlink (config.pidpath) < 0) {
|
if (config.pidpath != NULL && unlink (config.pidpath) < 0) {
|
||||||
log_message (LOG_WARNING,
|
log_message (LOG_WARNING,
|
||||||
"Could not remove PID file \"%s\": %s.",
|
"Could not remove PID file \"%s\": %s.",
|
||||||
config.pidpath, strerror (errno));
|
config.pidpath, strerror (errno));
|
||||||
|
Loading…
Reference in New Issue
Block a user