Bug #13822 embedded server closes stderr
Submitted: 6 Oct 2005 21:32 Modified: 14 Sep 2006 15:39
Reporter: Wez Furlong Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Server: Embedded Library ( libmysqld ) Severity:S2 (Serious)
Version:4.1.14 OS:Any (any)
Assigned to: Assigned Account CPU Architecture:Any

[6 Oct 2005 21:32] Wez Furlong
Description:
libmysqld unilaterally closes stdout/stderr.  This is bad.

How to repeat:
link against libmysqld and call mysql_server_init() and stdout/stderr are magically closed on your behalf.

Suggested fix:
Don't close() stdout/stderr when running embedded.
[9 Oct 2005 23:56] Hartmut Holzgraefe
most likely caused by these lines in sql/mysqld.cc?

#ifndef EMBEDDED_LIBRARY
      if (freopen(log_error_file, "a+", stdout))
#endif
        stderror_file= freopen(log_error_file, "a+", stderr);
[10 Oct 2005 18:46] Sergei Golubchik
a duplicate of bug#13717
[17 Dec 2005 23:29] Wez Furlong
It's not the same as #13717.
It's still not fixed in 4.1.16
[17 Dec 2005 23:47] Wez Furlong
This seems to fix it for me:

#ifndef EMBEDDED_LIBRARY
      if (freopen(log_error_file, "a+", stdout))
	stderror_file= freopen(log_error_file, "a+", stderr);
#else
	stderror_file= fopen(log_error_file, "a+");
#endif

In general, freopen() is an evil function if you don't own the process.
[14 Aug 2006 15:39] Alexey Botchkov
I tested it on Linux, version 4.1.22 - found no problem with the stderr.
Probably it was fixed with previous patches

Do you still have that problem?
[14 Sep 2006 23:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".