diff -urN xeno-unstable.orig/tools/python/xen/lowlevel/xu/xu.c xeno-unstable.cloexec/tools/python/xen/lowlevel/xu/xu.c --- xeno-unstable.orig/tools/python/xen/lowlevel/xu/xu.c 2004-08-12 00:51:23.000000000 -0700 +++ xeno-unstable.cloexec/tools/python/xen/lowlevel/xu/xu.c 2004-08-12 12:40:05.000000000 -0700 @@ -50,6 +50,19 @@ #define PAGE_SIZE 4096 +/* Set the close-on-exec flag on a file descriptor. Doesn't currently bother + * to check for errors. */ +static void set_cloexec(int fd) +{ + int flags = fcntl(fd, F_GETFD, 0); + + if ( flags < 0 ) + return; + + flags |= FD_CLOEXEC; + fcntl(fd, F_SETFD, flags); +} + /* * *********************** NOTIFIER *********************** */ @@ -190,6 +203,7 @@ PyObject_Del((PyObject *)xun); return PyErr_SetFromErrno(PyExc_IOError); } + set_cloexec(xun->evtchn_fd); return (PyObject *)xun; } @@ -881,6 +895,7 @@ PyErr_SetString(port_error, "Could not open '/dev/mem'"); return -1; } + set_cloexec(xup->mem_fd); /* Set the General-Purpose Subject whose page frame will be mapped. */ (void)ioctl(xup->mem_fd, _IO('M', 1), (unsigned long)xup->remote_dom);