From 7017b1838a6da02450a3e169c52ae156a9ab9b81 Mon Sep 17 00:00:00 2001 From: virusdefender Date: Sat, 16 Jan 2016 01:31:26 +0800 Subject: [PATCH] add some comment --- runner.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/runner.c b/runner.c index 7e1eb94..6e0bec9 100644 --- a/runner.c +++ b/runner.c @@ -117,7 +117,7 @@ int run(struct config *config, struct result *result) { return SUCCESS; } else { - //child process + // child process print("I'm child process\n"); // On success, these system calls return 0. // On error, -1 is returned, and errno is set appropriately. @@ -137,12 +137,14 @@ int run(struct config *config, struct result *result) { } // read stdin from in file - if (dup2(fileno(fopen(config->in_file, "r")), 0)) { + // On success, these system calls return the new descriptor. + // On error, -1 is returned, and errno is set appropriately. + if (dup2(fileno(fopen(config->in_file, "r")), 0) == -1) { print("dup2 stdin failed"); return DUP2_FAILED; } // write stdout to out file - if (dup2(fileno(fopen(config->out_file, "w")), 1)) { + if (dup2(fileno(fopen(config->out_file, "w")), 1) == -1) { print("dup2 stdout failed"); return DUP2_FAILED; } @@ -151,4 +153,4 @@ int run(struct config *config, struct result *result) { print("execve failed"); return EXCEVE_FAILED; } -} \ No newline at end of file +}