[syslinux] [PATCH] Create /var/run/tftpd-hpa.pid in standalone mode

Ferenc Wagner wferi at niif.hu
Sat Jul 4 16:04:56 PDT 2009


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




More information about the Syslinux mailing list