mirror of
https://github.com/samhocevar/rinetd.git
synced 2025-03-22 15:50:08 +08:00
Do not always try to write PID file in foreground mode.
This sounds like a reasonable default behaviour: if in foreground mode, AND pidlogfile is not specified in the configuration file, then we most probably do not want to write a PID file.
This commit is contained in:
parent
7f9f97a963
commit
79f2e14e22
18
rinetd.c
18
rinetd.c
@ -155,7 +155,7 @@ static int getConfLine(FILE *in, char *line, int space, int *lnum);
|
|||||||
static void clearConfiguration(void);
|
static void clearConfiguration(void);
|
||||||
static void readConfiguration(char const *file);
|
static void readConfiguration(char const *file);
|
||||||
|
|
||||||
static void registerPID(void);
|
static void registerPID(char const *pid_file_name);
|
||||||
static void logEvent(ConnectionInfo const *cnx, ServerInfo const *srv, int result);
|
static void logEvent(ConnectionInfo const *cnx, ServerInfo const *srv, int result);
|
||||||
static struct tm *get_gmtoff(int *tz);
|
static struct tm *get_gmtoff(int *tz);
|
||||||
|
|
||||||
@ -216,7 +216,9 @@ int main(int argc, char *argv[])
|
|||||||
signal(SIGTERM, quit);
|
signal(SIGTERM, quit);
|
||||||
|
|
||||||
readConfiguration(options.conf_file);
|
readConfiguration(options.conf_file);
|
||||||
registerPID();
|
if (pidLogFileName || !options.foreground) {
|
||||||
|
registerPID(pidLogFileName ? pidLogFileName : RINETD_PID_FILE);
|
||||||
|
}
|
||||||
|
|
||||||
syslog(LOG_INFO, "Starting redirections...");
|
syslog(LOG_INFO, "Starting redirections...");
|
||||||
while (1) {
|
while (1) {
|
||||||
@ -822,14 +824,9 @@ RETSIGTYPE quit(int s)
|
|||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void registerPID(void)
|
void registerPID(char const *pid_file_name)
|
||||||
{
|
{
|
||||||
char const *pid_file_name = RINETD_PID_FILE;
|
#if defined(__linux__)
|
||||||
if (pidLogFileName) {
|
|
||||||
pid_file_name = pidLogFileName;
|
|
||||||
}
|
|
||||||
/* add other systems with wherever they register processes */
|
|
||||||
#if defined(__linux__)
|
|
||||||
FILE *pid_file = fopen(pid_file_name, "w");
|
FILE *pid_file = fopen(pid_file_name, "w");
|
||||||
if (pid_file == NULL) {
|
if (pid_file == NULL) {
|
||||||
/* non-fatal, non-Linux may lack /var/run... */
|
/* non-fatal, non-Linux may lack /var/run... */
|
||||||
@ -847,8 +844,9 @@ error:
|
|||||||
syslog(LOG_ERR, "Couldn't write to "
|
syslog(LOG_ERR, "Couldn't write to "
|
||||||
"%s. PID was not logged (%m).\n", pid_file_name);
|
"%s. PID was not logged (%m).\n", pid_file_name);
|
||||||
#else
|
#else
|
||||||
|
/* add other systems with wherever they register processes */
|
||||||
(void)pid_file_name;
|
(void)pid_file_name;
|
||||||
#endif /* __linux__ */
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void logEvent(ConnectionInfo const *cnx, ServerInfo const *srv, int result)
|
static void logEvent(ConnectionInfo const *cnx, ServerInfo const *srv, int result)
|
||||||
|
Loading…
Reference in New Issue
Block a user