[PATCH 5/8] cr_tests: simple: Fix stdio

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The perror() after calling checkpoint() is useless -- stderr is closed.
Fix it by using dup2() to redirect stderr to the specified file. Do
the same for stdout just in case we want to use printf later.

Signed-off-by: Matt Helsley <matthltc@xxxxxxxxxx>
---
 simple/ckpt.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/simple/ckpt.c b/simple/ckpt.c
index 739eb0a..2f7d0bb 100644
--- a/simple/ckpt.c
+++ b/simple/ckpt.c
@@ -62,8 +62,8 @@ int main(int argc, char *argv[])
 
 	/* TODO these may no longer need to be closed? */
 	close(0);
-	close(1);
-	close(2);
+	dup2(fileno(file), 1);
+	dup2(fileno(file), 2);
 
 	fprintf(file, "hello, world!\n");
 	fflush(file);
-- 
1.6.3.3

_______________________________________________
Containers mailing list
Containers@xxxxxxxxxxxxxxxxxxxxxxxxxx
https://lists.linux-foundation.org/mailman/listinfo/containers

[Index of Archives]     [Cgroups]     [Netdev]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux