Mean value theorem on an open interval
The function $g(x)$ is non-negative and $g(x)\in R[a;b]$. The function $f(x)$ is continuous on the open interval $(a;b)$. The product $f(x)g(x)$ is Riemann integrable on the closed interval $[a;b]$.
Prove that the Mean value theorem holds under these conditions, i.e. there is a number $m\in[\inf f(x);\sup f(x)]$, such that $$\int_a^bf(x)g(x)dx = m\int_a^bg(x)dx.$$
Can we say that if $f(x)g(x)$ is Riemann-integrable on the closed interval $[a;b]$, $f(x)$ will be continuous on the an closed interval $[a;b]$? Or should I prove it as a normal Mean value theorem, ignoring the open interval?
Upd: It seems that problem is related to fact that $f(x)$ may not exist at points $a$ and $b$. And then I should probably consider it as an improper integral (although, for me, it is not clear how)
Assume $f$ bounded on $[a, b] $ with supremum $M$ and infimum $m$. Then using $m\leq f(x) \leq M$ we get $$mg(x) \leq f(x)g(x) \leq Mg(x)\tag{1} $$ and integrating we get $$m\int_a^b g(x) \, dx\leq \int_a^b f(x) g(x) \, dx\leq M\int_a^b g(x) \, dx\tag{2}$$ If $\int_a^b g(x) \, dx>0$ then dividing $(2)$ by $\int_a^b g(x) \, dx$ we see that $$\mu=\left. \int_a^b f(x) g(x) \, dx\middle/\int_a^b g(x) \, dx\right. $$ lies between $m$ and $M$.
If on the other hand $\int_a^b g(x) \, dx=0$ then $g$ vanishes at its points of continuity and at these same points $fg$ also vanishes and one can prove that its integral is $0$ (one can use the fact that $fg$ vanishes almost everywhere or use Cauchy Schwartz inequality because $f$ is also Riemann integrable) and then the relation $$\int_a^b f(x) g(x) \, dx=\mu\int_a^b g(x) \, dx$$ holds for every value of $\mu$.
Next we can consider the cases separately when 1) $m$ is finite and $M=\infty$, 2) $m=-\infty$ and $M$ is finite and 3) $m=-\infty, M=\infty$.
In handling these cases we can't use Cauchy Schwartz but need to rely on a little bit of measure theory as we can't be sure whether $f$ is Riemann integrable.
Also observe that continuity of $f$ is not used here in a fundamental way. The result holds if $f$ is assumed Riemann integrable on $[a, b] $.