Implement daemonization in bin/pattyd
Implement daemonization in bin/pattyd using daemon(3)
This commit is contained in:
parent
188d43f98d
commit
bb118be462
2 changed files with 10 additions and 4 deletions
|
@ -52,9 +52,5 @@ as a KISS interface, and zero or more optional
|
||||||
given to specify baud rate or flow control. Valid settings are:
|
given to specify baud rate or flow control. Valid settings are:
|
||||||
.Li 1200 , 9600 , crtscts , xonxoff .
|
.Li 1200 , 9600 , crtscts , xonxoff .
|
||||||
.El
|
.El
|
||||||
.Sh BUGS
|
|
||||||
The daemon does not support forking at this time. The
|
|
||||||
.Fl f
|
|
||||||
flag has no effect until this is implemented.
|
|
||||||
.Sh AUTHORS
|
.Sh AUTHORS
|
||||||
.An XANTRONIX Development Aq Mt dev@xantronix.com
|
.An XANTRONIX Development Aq Mt dev@xantronix.com
|
||||||
|
|
10
bin/pattyd.c
10
bin/pattyd.c
|
@ -436,6 +436,15 @@ int main(int argc, char **argv) {
|
||||||
goto error_config;
|
goto error_config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!flags[FLAG_FG]) {
|
||||||
|
if (daemon(1, 0) < 0) {
|
||||||
|
fprintf(stderr, "%s: %s: %s\n",
|
||||||
|
argv[0], "daemon()", strerror(errno));
|
||||||
|
|
||||||
|
goto error_daemon;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (patty_daemon_run(ctx.daemon) < 0) {
|
if (patty_daemon_run(ctx.daemon) < 0) {
|
||||||
fprintf(stderr, "%s: %s: %s\n",
|
fprintf(stderr, "%s: %s: %s\n",
|
||||||
argv[0], "patty_daemon_run()", strerror(errno));
|
argv[0], "patty_daemon_run()", strerror(errno));
|
||||||
|
@ -447,6 +456,7 @@ int main(int argc, char **argv) {
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
error_daemon:
|
||||||
error_daemon_run:
|
error_daemon_run:
|
||||||
error_config:
|
error_config:
|
||||||
error_invalid_args:
|
error_invalid_args:
|
||||||
|
|
Loading…
Add table
Reference in a new issue