aboutsummaryrefslogtreecommitdiff
path: root/Carpet
diff options
context:
space:
mode:
authorErik Schnetter <schnetter@gmail.com>2012-12-26 12:09:50 -0500
committerErik Schnetter <schnetter@gmail.com>2012-12-26 12:09:50 -0500
commitcdd5d0db583dbf1713822c06e8bd64b114b4564d (patch)
tree2cd05c0d133d4810d4102e28e2ff46535178d1a6 /Carpet
parenta60b2971fc200c8f30e43579beb3770ff30af422 (diff)
Carpet: Use dup2 instead of dup do control destination file descriptor
Diffstat (limited to 'Carpet')
-rw-r--r--Carpet/Carpet/src/TimerSet.cc13
1 files changed, 9 insertions, 4 deletions
diff --git a/Carpet/Carpet/src/TimerSet.cc b/Carpet/Carpet/src/TimerSet.cc
index ca9dc8077..20b81caa6 100644
--- a/Carpet/Carpet/src/TimerSet.cc
+++ b/Carpet/Carpet/src/TimerSet.cc
@@ -123,8 +123,9 @@ namespace Carpet {
close (oldfd);
return -1;
}
- close (1);
- int const fd = dup (fdfile); // dup to 1, i.e., stdout again
+ // close (1);
+ // int const fd = dup (fdfile); // dup to 1, i.e., stdout again
+ int const fd = dup2 (fdfile, 1); // dup to 1, i.e., stdout again
assert (fd == 1);
close (fdfile);
return oldfd;
@@ -139,8 +140,12 @@ namespace Carpet {
#ifdef HAVE_UNISTD_H
fflush (stdout);
- close (1);
- int const fd = dup (oldfd);
+ // close (1);
+ // int const fd = dup (oldfd);
+ int const fd = dup2 (oldfd, 1);
+ if (not (fd == 1)) {
+ fprintf(stderr, "oldfd=%d fd=%d\n", oldfd, fd);
+ }
assert (fd == 1);
close (oldfd);
#endif