diff options
author | kaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk> | 2005-08-04 18:51:55 +0000 |
---|---|---|
committer | kaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk> | 2005-08-04 18:51:55 +0000 |
commit | 11269655409bf6f913b22a816b8f8552070af1b1 (patch) | |
tree | 632ed9ae49754a571f1e7fdfe69224be6bc5535f /tools/xenstore/utils.c | |
parent | 55b7c09016e4a043351b84e85ee6132578e882f4 (diff) | |
download | xen-11269655409bf6f913b22a816b8f8552070af1b1.tar.gz xen-11269655409bf6f913b22a816b8f8552070af1b1.tar.bz2 xen-11269655409bf6f913b22a816b8f8552070af1b1.zip |
Attached are
three patches to fix a problem with Xend starting consoled. consoled
depends on xenstored to be running and xenstored is started on demand in
Xend. The patches change xenstored to manage its own pidfile, and have
xend start actually start up xenstored.
Diffstat (limited to 'tools/xenstore/utils.c')
-rw-r--r-- | tools/xenstore/utils.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tools/xenstore/utils.c b/tools/xenstore/utils.c index 0b1ac8aedd..cc5e0bc5f2 100644 --- a/tools/xenstore/utils.c +++ b/tools/xenstore/utils.c @@ -84,6 +84,9 @@ void *malloc_nofail(size_t size) void daemonize(void) { pid_t pid; + int fd; + size_t len; + char buf[100]; /* Separate from our parent via fork, so init inherits us. */ if ((pid = fork()) < 0) @@ -101,6 +104,18 @@ void daemonize(void) chdir("/"); /* Discard our parent's old-fashioned umask prejudices. */ umask(0); + + fd = open("/var/run/xenstored.pid", O_RDWR | O_CREAT); + if (fd == -1) { + exit(1); + } + + if (lockf(fd, F_TLOCK, 0) == -1) { + exit(1); + } + + len = sprintf(buf, "%d\n", getpid()); + write(fd, buf, len); } |