guacd should fork self into background, like any self-respecting daemon.
This commit is contained in:
parent
866e8fa7c7
commit
e45c8be4da
@ -85,6 +85,9 @@ int main(int argc, char* argv[]) {
|
|||||||
int listen_port = 4822; /* Default port */
|
int listen_port = 4822; /* Default port */
|
||||||
int opt;
|
int opt;
|
||||||
|
|
||||||
|
/* Daemon Process */
|
||||||
|
pid_t daemon_pid;
|
||||||
|
|
||||||
/* Parse arguments */
|
/* Parse arguments */
|
||||||
while ((opt = getopt(argc, argv, "l:")) != -1) {
|
while ((opt = getopt(argc, argv, "l:")) != -1) {
|
||||||
if (opt == 'l') {
|
if (opt == 'l') {
|
||||||
@ -120,8 +123,22 @@ int main(int argc, char* argv[]) {
|
|||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
syslog(LOG_INFO, "Started, listening on port %i", listen_port);
|
/* Fork into background */
|
||||||
|
daemon_pid = fork();
|
||||||
|
|
||||||
|
/* If error, fail */
|
||||||
|
if (daemon_pid == -1) {
|
||||||
|
fprintf(stderr, "Error forking daemon process: %s\n", strerror(errno));
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If parent, exit */
|
||||||
|
else if (daemon_pid != 0) {
|
||||||
|
exit(EXIT_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Otherwise, this is the daemon */
|
||||||
|
syslog(LOG_INFO, "Started, listening on port %i", listen_port);
|
||||||
|
|
||||||
/* Daemon loop */
|
/* Daemon loop */
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
Loading…
Reference in New Issue
Block a user