summaryrefslogtreecommitdiffstats
path: root/runtime/staprun/common.c
diff options
context:
space:
mode:
authorFrank Ch. Eigler <fche@elastic.org>2007-10-10 13:58:43 -0400
committerFrank Ch. Eigler <fche@elastic.org>2007-10-10 13:58:43 -0400
commit36c24cdba10c3d20638c78b52cc8e327a3a0b82d (patch)
tree24cbeb006365fdaa21dbf9cf3b44eae055684123 /runtime/staprun/common.c
parent38d7fc30b108ec4a9e74ddb33d945cce1bd5c4c6 (diff)
parentd319669c3f77a3e451f1cad845471433e6d0dbfa (diff)
downloadsystemtap-steved-36c24cdba10c3d20638c78b52cc8e327a3a0b82d.tar.gz
systemtap-steved-36c24cdba10c3d20638c78b52cc8e327a3a0b82d.tar.xz
systemtap-steved-36c24cdba10c3d20638c78b52cc8e327a3a0b82d.zip
Merge branch 'master' of git://sources.redhat.com/git/systemtap
Diffstat (limited to 'runtime/staprun/common.c')
-rw-r--r--runtime/staprun/common.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/runtime/staprun/common.c b/runtime/staprun/common.c
index d3f8835a..47778efd 100644
--- a/runtime/staprun/common.c
+++ b/runtime/staprun/common.c
@@ -315,3 +315,22 @@ int send_request(int type, void *data, int len)
memcpy(&buf[4], data, len);
return write(control_channel, buf, len+4);
}
+
+/*
+ * set FD_CLOEXEC for any file descriptor
+ */
+int set_clexec(int fd)
+{
+ int val;
+ if ((val = fcntl(fd, F_GETFD, 0)) < 0)
+ goto err;
+
+ if ((val = fcntl(fd, F_SETFD, val | FD_CLOEXEC)) < 0)
+ goto err;
+
+ return 0;
+err:
+ perr("fcntl failed");
+ close(fd);
+ return -1;
+}