Don't return if /proc couldn't be read

This commit is contained in:
rdb 2010-11-26 21:55:57 +00:00
parent 6fab399549
commit 304dd37afa

View File

@ -659,35 +659,32 @@ read_args() {
pifstream proc("/proc/curproc/cmdline"); pifstream proc("/proc/curproc/cmdline");
if (proc.fail()) { if (proc.fail()) {
cerr << "Cannot read /proc/curproc/cmdline; command-line arguments unavailable to config.\n"; cerr << "Cannot read /proc/curproc/cmdline; command-line arguments unavailable to config.\n";
return;
}
#else #else
pifstream proc("/proc/self/cmdline"); pifstream proc("/proc/self/cmdline");
if (proc.fail()) { if (proc.fail()) {
cerr << "Cannot read /proc/self/cmdline; command-line arguments unavailable to config.\n"; cerr << "Cannot read /proc/self/cmdline; command-line arguments unavailable to config.\n";
return;
}
#endif #endif
} else {
int ch = proc.get();
int index = 0;
while (!proc.eof() && !proc.fail()) {
string arg;
int ch = proc.get(); while (!proc.eof() && !proc.fail() && ch != '\0') {
int index = 0; arg += (char)ch;
while (!proc.eof() && !proc.fail()) { ch = proc.get();
string arg; }
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(); ch = proc.get();
} }
if (index == 0) {
if (_binary_name.empty())
_binary_name = arg;
} else {
_args.push_back(arg);
}
index++;
ch = proc.get();
} }
#endif #endif