diff --git a/tftpd/tftpd.8.in b/tftpd/tftpd.8.in index ea1697c..e645d37 100644 --- a/tftpd/tftpd.8.in +++ b/tftpd/tftpd.8.in @@ -59,6 +59,11 @@ option is ignored, and the option can be used to specify a specific local address or port to listen to. .TP +.B \-L +Similar to +.B \-l +but do not detach from the foreground process. +.TP \fB\-a\fP \fI[address][:port]\fP Specify a specific .I address @@ -66,6 +71,8 @@ and .I port to listen to when called with the .B \-l +or +.B \-L option. The default is to listen to the .I tftp port specified in diff --git a/tftpd/tftpd.c b/tftpd/tftpd.c index ee65b10..a1f30f6 100644 --- a/tftpd/tftpd.c +++ b/tftpd/tftpd.c @@ -283,6 +283,7 @@ main(int argc, char **argv) int n; int fd = 0; int standalone = 0; /* Standalone (listen) mode */ + int nodaemon = 0; /* Do not detach process */ char *address = NULL; /* Address to listen to */ pid_t pid; mode_t my_umask = 0; @@ -306,7 +307,7 @@ main(int argc, char **argv) srand(time(NULL) ^ getpid()); - while ((c = getopt(argc, argv, "cspvVla:B:u:U:r:t:T:R:m:")) != -1) + while ((c = getopt(argc, argv, "cspvVlLa:B:u:U:r:t:T:R:m:")) != -1) switch (c) { case 'c': cancreate = 1; @@ -320,6 +321,10 @@ main(int argc, char **argv) case 'l': standalone = 1; break; + case 'L': + standalone = 1; + nodaemon = 1; + break; case 'a': address = optarg; break; @@ -497,7 +502,7 @@ main(int argc, char **argv) } /* Daemonize this process */ - if (daemon(0, 0) < 0) { + if (!nodaemon && daemon(0, 0) < 0) { syslog(LOG_ERR, "cannot daemonize: %m"); exit(EX_OSERR); }