From 304dd37afa0b6a9363b711d9e8a8f5f2a080f32e Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 26 Nov 2010 21:55:57 +0000 Subject: [PATCH] Don't return if /proc couldn't be read --- dtool/src/dtoolutil/executionEnvironment.cxx | 37 +++++++++----------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/dtool/src/dtoolutil/executionEnvironment.cxx b/dtool/src/dtoolutil/executionEnvironment.cxx index b6bfa408a0..65b254f243 100644 --- a/dtool/src/dtoolutil/executionEnvironment.cxx +++ b/dtool/src/dtoolutil/executionEnvironment.cxx @@ -659,35 +659,32 @@ read_args() { pifstream proc("/proc/curproc/cmdline"); if (proc.fail()) { cerr << "Cannot read /proc/curproc/cmdline; command-line arguments unavailable to config.\n"; - return; - } #else pifstream proc("/proc/self/cmdline"); if (proc.fail()) { cerr << "Cannot read /proc/self/cmdline; command-line arguments unavailable to config.\n"; - return; - } #endif + } else { + int ch = proc.get(); + int index = 0; + while (!proc.eof() && !proc.fail()) { + string arg; - int ch = proc.get(); - int index = 0; - while (!proc.eof() && !proc.fail()) { - string arg; + while (!proc.eof() && !proc.fail() && ch != '\0') { + arg += (char)ch; + ch = proc.get(); + } + + if (index == 0) { + if (_binary_name.empty()) + _binary_name = arg; + } else { + _args.push_back(arg); + } + index++; - while (!proc.eof() && !proc.fail() && ch != '\0') { - arg += (char)ch; ch = proc.get(); } - - if (index == 0) { - if (_binary_name.empty()) - _binary_name = arg; - } else { - _args.push_back(arg); - } - index++; - - ch = proc.get(); } #endif