Set FD_CLOEXEC on the pidfile fd, so that tapdisk does not get it.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
This commit is contained in:
Ewan Mellor committed 2006-12-14 10:31:31 +00:00
1 parent e6be7d74b9
commit 62184014df
1 file changed
+13
+13
View File
@@ -629,6 +629,7 @@ static void write_pidfile(long pid)
char buf[100];
int len;
int fd;
int flags;
fd = open(PIDFILE, O_RDWR | O_CREAT, 0600);
if (fd == -1) {
@@ -640,6 +641,18 @@ static void write_pidfile(long pid)
if (lockf(fd, F_TLOCK, 0) == -1)
exit(0);
/* Set FD_CLOEXEC, so that tapdisk doesn't get this file
descriptor. */
if ((flags = fcntl(fd, F_GETFD)) == -1) {
DPRINTF("F_GETFD failed (%d)\n", errno);
exit(1);
}
flags |= FD_CLOEXEC;
if (fcntl(fd, F_SETFD, flags) == -1) {
DPRINTF("F_SETFD failed (%d)\n", errno);
exit(1);
}
len = sprintf(buf, "%ld\n", pid);
if (write(fd, buf, len) != len) {
DPRINTF("Writing pid file failed (%d)\n", errno);
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.