ia64/xen-unstable

changeset 6767:d22091179975

Check the return value of chdir(2) and write(2).
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
author cl349@firebug.cl.cam.ac.uk
date Mon Sep 12 20:24:58 2005 +0000 (2005-09-12)
parents 219d96d545fc
children 282d5698ea40
files tools/console/daemon/utils.c
line diff
     1.1 --- a/tools/console/daemon/utils.c	Mon Sep 12 20:00:41 2005 +0000
     1.2 +++ b/tools/console/daemon/utils.c	Mon Sep 12 20:24:58 2005 +0000
     1.3 @@ -105,7 +105,8 @@ void daemonize(const char *pidfile)
     1.4  	close(fd);
     1.5  
     1.6  	umask(027);
     1.7 -	chdir("/");
     1.8 +	if (chdir("/") < 0)
     1.9 +		exit (1);
    1.10  
    1.11  	fd = open(pidfile, O_RDWR | O_CREAT);
    1.12  	if (fd == -1) {
    1.13 @@ -117,7 +118,8 @@ void daemonize(const char *pidfile)
    1.14  	}
    1.15  
    1.16  	len = sprintf(buf, "%d\n", getpid());
    1.17 -	write(fd, buf, len);
    1.18 +	if (write(fd, buf, len) < 0)
    1.19 +		exit(1);
    1.20  
    1.21  	signal(SIGCHLD, child_exit);
    1.22  	signal(SIGTSTP, SIG_IGN);