# HG changeset patch # User cl349@firebug.cl.cam.ac.uk # Date 1126556698 0 # Node ID d22091179975853b0438c937aaea239d92b83832 # Parent 219d96d545fcb918d1abc45688975af86728b408 Check the return value of chdir(2) and write(2). Signed-off-by: Christian Limpach diff -r 219d96d545fc -r d22091179975 tools/console/daemon/utils.c --- a/tools/console/daemon/utils.c Mon Sep 12 20:00:41 2005 +0000 +++ b/tools/console/daemon/utils.c Mon Sep 12 20:24:58 2005 +0000 @@ -105,7 +105,8 @@ void daemonize(const char *pidfile) close(fd); umask(027); - chdir("/"); + if (chdir("/") < 0) + exit (1); fd = open(pidfile, O_RDWR | O_CREAT); if (fd == -1) { @@ -117,7 +118,8 @@ void daemonize(const char *pidfile) } len = sprintf(buf, "%d\n", getpid()); - write(fd, buf, len); + if (write(fd, buf, len) < 0) + exit(1); signal(SIGCHLD, child_exit); signal(SIGTSTP, SIG_IGN);