From b832cdc1c7e462ca7c87ea16abdf694bac1bc272 Mon Sep 17 00:00:00 2001 From: Andrew Deason Date: Wed, 4 Aug 2010 11:19:35 -0500 Subject: [PATCH] rxgen: Error out if cpp exits with error If we call 'cpp' and it returns with an erroneous exit code, exit with an error ourselves. Otherwise we will return success and generate empty results even if the input file is unreadable, for instance, which causes confusing errors later in the build. Change-Id: Ia12dc58eee0937a6bd529dcd6b552e253dbc40c8 Reviewed-on: http://gerrit.openafs.org/2519 Tested-by: BuildBot Reviewed-by: Derrick Brashear Tested-by: Derrick Brashear --- src/rxgen/rpc_main.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/rxgen/rpc_main.c b/src/rxgen/rpc_main.c index 5c02c16..37d2a8a 100644 --- a/src/rxgen/rpc_main.c +++ b/src/rxgen/rpc_main.c @@ -91,6 +91,7 @@ char zflag = 0; /* If set, abort server stub if rpc call returns non-zero */ char xflag = 0; /* if set, add stats code to stubs */ char yflag = 0; /* if set, only emit function name arrays to xdr file */ int debug = 0; +static int pclose_fin = 0; static char *cmdname; #ifdef AFS_NT40_ENV static char *CPP = NULL; @@ -223,6 +224,12 @@ main(int argc, char *argv[]) reinitialize(); } } + if (fin && pclose_fin) { + /* the cpp command we called returned a non-zero exit status */ + if (pclose(fin)) { + crash(); + } + } exit(0); } @@ -313,6 +320,7 @@ open_input(char *infile, char *define) fin = popen(cpp_cmdline, "r"); if (fin == NULL) perror("popen"); + pclose_fin = 1; } else { if (infile == NULL) { -- 1.9.4