fstream::open crashes if first file it ever opening is in /proc

Csaba Raduly rcsaba@gmail.com
Thu Jul 8 08:53:09 GMT 2021


On Thu, 8 Jul 2021 at 07:42, Max Mikhanosha via Cygwin
<cygwin@cygwin.com> wrote:
>
> Fully updated Windows 10, with freshly downloaded Cygwin.
>
> trying to compile google/benchmark does not work coz it can't read /proc/cpuinfo
>
> Reduced test test program
>
> #include <iostream>
> #include <fstream>
>
> int main (int argc, char **argv)
> {
>   if (argc > 1)
>   {
>     std::fstream booya ("whatever");
>   }
>   std::fstream f("/proc/cpuinfo");
>   if (!f.is_open ()){
>     std::cout << "Unable to open /proc/cpuinfo" << std::endl;
>   }
>   return 0;
> }
>
> Repro log
>
>
> user@MARS ~
> $ g++ blah.cc
>
> user@MARS ~
> $ ./a.exe    # this does not work
> Unable to open /proc/cpuinfo
>
> user@MARS ~
> $ ./a.exe foobar   # this works
>

Works just fine for me (I added code to read the first word from the
stream and print it)

Csaba@AMDAHL ~
$ ./a.exe
processor
Csaba@AMDAHL ~
$ ./a.exe  foobar
processor

Csaba
-- 
You can get very substantial performance improvements
by not doing the right thing. - Scott Meyers, An Effective C++11/14 Sampler
So if you're looking for a completely portable, 100% standards-conformant way
to get the wrong information: this is what you want. - Scott Meyers (C++TDaWYK)


More information about the Cygwin mailing list