Information on a commit related to libstdc++/9533

Paolo Carlini pcarlini@unitus.it
Mon Mar 3 13:03:00 GMT 2003


Nathan Myers wrote:

>I agree that this is a very serious problem.  Setting non-blocking
>mode is a radical change to expected semantics, so that if that mode 
>is not available, it cannot be right just to leave it off.  
>
>I think the real error is in setting non-blocking mode: that cannot be 
>the right solution to whatever problem it meant to solve.  I don't know 
>what problem it was meant to solve.  I do know that we have had iostream 
>implementations for more than a decade that perform well on both files 
>and ttys and do not depend on setting a non-blocking mode.
>
Thanks Nathan for your feedback: in fact, just reverting the hunk of 6746
which sets the non-blocking mode (see 9533 audit trail) appears to fix
the problem without regressing on 6746.

But... regtesting we got the failure of this test ("fail bit was not set!"):

// libstdc++/2913, libstdc++/4879
// John Fardo  <jfardo@laurelnetworks.com>, Brad Garcia <garsh@attbi.com>
void
test_04()
{
  signal(SIGPIPE, SIG_IGN);
 
  if (0 != mkfifo("xxx", S_IRWXU))
    {
      std::cerr << "failed to creat fifo" << std::endl;
      exit(-1);
    }
 
  int fval = fork();
  if (fval == -1)
    {
      std::cerr << "failed to fork" << std::endl;
      unlink("xxx");
      exit(-1);
    }
  else if (fval == 0)
    {
      std::ifstream ifs("xxx");
      sleep(1);
      ifs.close();
      exit(0);
    }

  std::ofstream ofs("xxx");
  sleep(2);
  ofs.put('t');

  /*
   * ISO/IED 14882:1998(E) 27.8.1.10.4
   *
   * void close();
   *
   * Effects:  Calls rdbuf()->close() and, if that function fails
   * (returns a null pointer), calls setstate(failbit)...
   */
  ofs.close();
  if (!(ofs.rdstate() & std::ios::failbit))
    {
      std::cerr << "fail bit was not set!" << std::endl;
      unlink("xxx");
      exit(-1);
    }

  unlink("xxx");
}

Ideas?

Thanks,
Paolo.



More information about the Libstdc++ mailing list