forked from mirrors/tftp-hpa-google
Add -L option to not daemonize process
This commit is contained in:
parent
059de7ce20
commit
d9938a7d83
2 changed files with 14 additions and 2 deletions
|
@ -59,6 +59,11 @@ option is ignored, and the
|
||||||
option can be used to specify a specific local address or port to
|
option can be used to specify a specific local address or port to
|
||||||
listen to.
|
listen to.
|
||||||
.TP
|
.TP
|
||||||
|
.B \-L
|
||||||
|
Similar to
|
||||||
|
.B \-l
|
||||||
|
but do not detach from the foreground process.
|
||||||
|
.TP
|
||||||
\fB\-a\fP \fI[address][:port]\fP
|
\fB\-a\fP \fI[address][:port]\fP
|
||||||
Specify a specific
|
Specify a specific
|
||||||
.I address
|
.I address
|
||||||
|
@ -66,6 +71,8 @@ and
|
||||||
.I port
|
.I port
|
||||||
to listen to when called with the
|
to listen to when called with the
|
||||||
.B \-l
|
.B \-l
|
||||||
|
or
|
||||||
|
.B \-L
|
||||||
option. The default is to listen to the
|
option. The default is to listen to the
|
||||||
.I tftp
|
.I tftp
|
||||||
port specified in
|
port specified in
|
||||||
|
|
|
@ -283,6 +283,7 @@ main(int argc, char **argv)
|
||||||
int n;
|
int n;
|
||||||
int fd = 0;
|
int fd = 0;
|
||||||
int standalone = 0; /* Standalone (listen) mode */
|
int standalone = 0; /* Standalone (listen) mode */
|
||||||
|
int nodaemon = 0; /* Do not detach process */
|
||||||
char *address = NULL; /* Address to listen to */
|
char *address = NULL; /* Address to listen to */
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
mode_t my_umask = 0;
|
mode_t my_umask = 0;
|
||||||
|
@ -306,7 +307,7 @@ main(int argc, char **argv)
|
||||||
|
|
||||||
srand(time(NULL) ^ getpid());
|
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) {
|
switch (c) {
|
||||||
case 'c':
|
case 'c':
|
||||||
cancreate = 1;
|
cancreate = 1;
|
||||||
|
@ -320,6 +321,10 @@ main(int argc, char **argv)
|
||||||
case 'l':
|
case 'l':
|
||||||
standalone = 1;
|
standalone = 1;
|
||||||
break;
|
break;
|
||||||
|
case 'L':
|
||||||
|
standalone = 1;
|
||||||
|
nodaemon = 1;
|
||||||
|
break;
|
||||||
case 'a':
|
case 'a':
|
||||||
address = optarg;
|
address = optarg;
|
||||||
break;
|
break;
|
||||||
|
@ -497,7 +502,7 @@ main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Daemonize this process */
|
/* Daemonize this process */
|
||||||
if (daemon(0, 0) < 0) {
|
if (!nodaemon && daemon(0, 0) < 0) {
|
||||||
syslog(LOG_ERR, "cannot daemonize: %m");
|
syslog(LOG_ERR, "cannot daemonize: %m");
|
||||||
exit(EX_OSERR);
|
exit(EX_OSERR);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue