Permalink
Browse files

on non-lsb linux distros, strip newline

  • Loading branch information...
1 parent 2041104 commit b4d9eb439b136dd822fc0c5adb1b201fc79c1eed @vrtx committed Feb 25, 2012
Showing with 8 additions and 2 deletions.
  1. +8 −2 src/mongo/util/processinfo_linux2.cpp
@@ -284,9 +284,15 @@ namespace mongo {
// file exists but can't be opened
return;
// read up to 512 bytes
- f.read( 0, buf, f.len() > 512 ? 512 : f.len() );
- buf[ (f.len() > 512 ? 512 : f.len()) ] = '\0';
+ int len = f.len() > 512 ? : 512 : f.len();
+ f.read( 0, buf, len );
+ buf[ len ] = '\0';
name = buf;
+ size_t nl = 0;
+ if ( ( nl = string.find( '\n', nl ) ) != string::npos )
+ // stop at first newline
+ string.erase( nl );
+
version = ""; // no standard format for name and version. needs additional parsing.
}

0 comments on commit b4d9eb4

Please sign in to comment.