[PATCH ocserv] main: check return of daemon()

Jason Cooper jason at lakedaemon.net
Tue Feb 26 11:10:40 EST 2013


Signed-off-by: Jason Cooper <jason at lakedaemon.net>
---
This silences the only warning outside of all the libopts warnings.

 src/main.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/main.c b/src/main.c
index f6beca7..1485f80 100644
--- a/src/main.c
+++ b/src/main.c
@@ -607,8 +607,12 @@ int main(int argc, char** argv)
 
 	memset(&ws, 0, sizeof(ws));
 	
-	if (config.foreground == 0)
-		daemon(0, 0);
+	if (config.foreground == 0) {
+		if (daemon(0, 0) == -1) {
+			fprintf(stderr, "daemon failed: %s\n", strerror(errno));
+			exit(1);
+		}
+	}
 
 	write_pid_file();
 
-- 
1.8.1.4




More information about the openconnect-devel mailing list