diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2006-07-26 13:32:44 +0000 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2006-07-26 13:32:44 +0000 |
commit | b102348e988e4abc5d579ce13c067ce2c885aaf7 (patch) | |
tree | f7df67ce818aa8720f956171765889684c528ee1 /dund | |
parent | abaf87668c896d8cebcfa1081eec195cd0008740 (diff) |
Fix declared with attribute warn_unused_result errors
Diffstat (limited to 'dund')
-rw-r--r-- | dund/dun.c | 6 | ||||
-rw-r--r-- | dund/main.c | 15 |
2 files changed, 8 insertions, 13 deletions
@@ -98,7 +98,9 @@ static int uses_rfcomm(char *path, char *dev) dir = opendir(path); if (!dir) return 0; - chdir(path); + + if (chdir(path) < 0) + return 0; while ((de = readdir(dir)) != NULL) { char link[PATH_MAX + 1]; @@ -109,7 +111,9 @@ static int uses_rfcomm(char *path, char *dev) return 1; } } + closedir(dir); + return 0; } diff --git a/dund/main.c b/dund/main.c index 249d6d7c..bb96d639 100644 --- a/dund/main.c +++ b/dund/main.c @@ -598,18 +598,9 @@ int main(int argc, char *argv[]) sa.sa_handler = sig_hup; sigaction(SIGHUP, &sa, NULL); - if (detach) { - int fd; - - if (fork()) exit(0); - - /* Direct stdin,stdout,stderr to '/dev/null' */ - fd = open("/dev/null", O_RDWR); - dup2(fd, 0); dup2(fd, 1); dup2(fd, 2); - close(fd); - - setsid(); - chdir("/"); + if (detach && daemon(0, 0)) { + perror("Can't start daemon"); + exit(1); } openlog("dund", LOG_PID | LOG_NDELAY | LOG_PERROR, LOG_DAEMON); |