summaryrefslogtreecommitdiffstats
path: root/runtime/staprun/relay_old.c
diff options
context:
space:
mode:
authorhunt <hunt>2007-10-09 16:03:04 +0000
committerhunt <hunt>2007-10-09 16:03:04 +0000
commit577e7ed19be74db082ba058016fd31b643495ebd (patch)
treec395a0e02f95de53044400fba71000c9e8f5bc3b /runtime/staprun/relay_old.c
parenta6053c5b3f42ef0e016df9074ebc75c93a79d544 (diff)
downloadsystemtap-steved-577e7ed19be74db082ba058016fd31b643495ebd.tar.gz
systemtap-steved-577e7ed19be74db082ba058016fd31b643495ebd.tar.xz
systemtap-steved-577e7ed19be74db082ba058016fd31b643495ebd.zip
2007-10-09 Martin Hunt <hunt@redhat.com>
* common.c (set_clexec): New. * staprun.h: Add prototype for set_clexec. * relay*.c, ctl.c: Call set_clexec after file opens.
Diffstat (limited to 'runtime/staprun/relay_old.c')
-rw-r--r--runtime/staprun/relay_old.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/runtime/staprun/relay_old.c b/runtime/staprun/relay_old.c
index 3f65acbb..f138aee5 100644
--- a/runtime/staprun/relay_old.c
+++ b/runtime/staprun/relay_old.c
@@ -86,7 +86,7 @@ static int open_relayfs_files(int cpu, const char *relay_filebase, const char *p
return -1;
dbug(2, "Opening %s.\n", tmp);
relay_fd[cpu] = open(tmp, O_RDONLY | O_NONBLOCK);
- if (relay_fd[cpu] < 0) {
+ if (relay_fd[cpu] < 0 || set_clexec(relay_fd[cpu]) < 0) {
relay_fd[cpu] = 0;
return 0;
}
@@ -99,6 +99,10 @@ static int open_relayfs_files(int cpu, const char *relay_filebase, const char *p
perr("Couldn't open proc file %s", tmp);
goto err1;
}
+ if (set_clexec(relay_fd[cpu]) < 0) {
+ relay_fd[cpu] = 0;
+ return -1;
+ }
if (outfile_name) {
/* special case: for testing we sometimes want to
@@ -118,6 +122,10 @@ static int open_relayfs_files(int cpu, const char *relay_filebase, const char *p
perr("Couldn't open output file %s", tmp);
goto err2;
}
+ if (set_clexec(fileno(percpu_tmpfile[cpu])) < 0) {
+ perr("Couldn't open output file %s", tmp);
+ goto err2;
+ }
total_bufsize = subbuf_size * n_subbufs;
relay_buffer[cpu] = mmap(NULL, total_bufsize, PROT_READ,
@@ -243,7 +251,7 @@ int init_oldrelayfs(void)
if (!bulkmode) {
if (outfile_name) {
out_fd[0] = open (outfile_name, O_CREAT|O_TRUNC|O_WRONLY, 0666);
- if (out_fd[0] < 0) {
+ if (out_fd[0] < 0 || set_clexec(out_fd[0]) < 0) {
perr("Couldn't open output file '%s'", outfile_name);
return -1;
}