Ferenc Wagner
2009-Jul-04 23:04 UTC
[syslinux] [PATCH] Create /var/run/tftpd-hpa.pid in standalone mode
This is more a question than a serious proposal. The name of the pid file should probably be configurable, and it should be unlinked on normal termination, but no such thing exists in standalone mode. SIGTERM and SIGINT should be catched and considered normal, I guess. Signed-off-by: Ferenc Wagner <wferi at niif.hu> --- tftpd/tftpd.c | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-) diff --git a/tftpd/tftpd.c b/tftpd/tftpd.c index 1f5d9d6..18896c9 100644 --- a/tftpd/tftpd.c +++ b/tftpd/tftpd.c @@ -517,6 +517,7 @@ int main(int argc, char **argv) /* If we're running standalone, set up the input port */ if (standalone) { + FILE *pidfile; #ifdef HAVE_IPV6 if (ai_fam != AF_INET6) { #endif @@ -702,6 +703,12 @@ int main(int argc, char **argv) syslog(LOG_ERR, "cannot daemonize: %m"); exit(EX_OSERR); } + pidfile = fopen ("/var/run/tfpd-hpa.pid","w"); + if (!pidfile + || fprintf(pidfile, "%d\n", getpid()) < 0 + || fclose(pidfile)) { + syslog(LOG_ERR, "cannot write pid file: %m"); + } if (fd6 > fd4) fdmax = fd6; else -- 1.5.6.5
H. Peter Anvin
2009-Jul-04 23:39 UTC
[syslinux] [PATCH] Create /var/run/tftpd-hpa.pid in standalone mode
Ferenc Wagner wrote:> This is more a question than a serious proposal. The name of the pid > file should probably be configurable, and it should be unlinked on > normal termination, but no such thing exists in standalone mode. > SIGTERM and SIGINT should be catched and considered normal, I guess.Yup, that pretty much sums it up. -hpa -- H. Peter Anvin, Intel Open Source Technology Center I work for Intel. I don't speak on their behalf.
H. Peter Anvin
2009-Jul-04 23:41 UTC
[syslinux] [PATCH] Create /var/run/tftpd-hpa.pid in standalone mode
Ferenc Wagner wrote:> This is more a question than a serious proposal. The name of the pid > file should probably be configurable, and it should be unlinked on > normal termination, but no such thing exists in standalone mode. > SIGTERM and SIGINT should be catched and considered normal, I guess.Actually, we probably should remove it even for abnormal termination... we obviously can't do anything about SIGKILL, but for others (SIGQUIT, SIGSEGV, ...) we probably should trap and remove the pid file... -hpa -- H. Peter Anvin, Intel Open Source Technology Center I work for Intel. I don't speak on their behalf.
Apparently Analagous Threads
- [PATCH] tftpd.c: write a pid file in standalone mode
- Bug#771441: [PATCH tftpd-hpa] tftpd: don't use AI_CANONNAME and AI_ADDRCONFIG to resolve addresses for bind
- [PATCH tftpd-hpa] tftpd: don't use AI_CANONNAME and AI_ADDRCONFIG to resolve addresses for bind
- [tftpd PATCH 0/5] pidfile option and syslog fix
- Bug#771441: [PATCH tftpd-hpa] tftpd: don't use AI_CANONNAME and AI_ADDRCONFIG to resolve addresses for bind