On Tue, Oct 9, 2012 at 10:14 PM, Peter Hutterer <[email protected]> wrote: > Startup failure can be a valid test-case, avoid throwing exceptions around. > Instead, update the process state on SIGCHLD, otherwise continue quietly > after the timeout. > A test that needs the server to be running, will figure out that it isn't > once XOpenDisplay() fails. > > If the signal handling fails, still throw an exception, that's an actual > error case. > > Signed-off-by: Peter Hutterer <[email protected]> > --- > src/xserver.cpp | 18 +++++++++++------- > 1 file changed, 11 insertions(+), 7 deletions(-) > > diff --git a/src/xserver.cpp b/src/xserver.cpp > index 082818c..1ba4e08 100644 > --- a/src/xserver.cpp > +++ b/src/xserver.cpp > @@ -308,6 +308,7 @@ void xorg::testing::XServer::Start(const std::string > &program) { > /* add SIGUSR1 to the signal mask */ > sigemptyset(&sig_mask); > sigaddset(&sig_mask, SIGUSR1); > + sigaddset(&sig_mask, SIGCHLD); > if (sigprocmask(SIG_BLOCK, &sig_mask, NULL)) { > err_msg.append("Failed to set signal mask: "); > err_msg.append(std::strerror(errno)); > @@ -337,16 +338,19 @@ void xorg::testing::XServer::Start(const std::string > &program) { > raise(SIGSTOP); > > /* wait for SIGUSR1 from XServer */ > - if (SIGUSR1 != sigtimedwait(&sig_mask, NULL, &sig_timeout)) { > - if (errno == EAGAIN) { > - err_msg.append("XServer startup timed out: "); > - } else { > + int recv_sig = sigtimedwait(&sig_mask, NULL, &sig_timeout); > + if (recv_sig == SIGCHLD) { > + GetState(); > + } else if (recv_sig != SIGUSR1 && errno != EAGAIN) { > err_msg.append("Error while waiting for XServer startup: "); > - } > - err_msg.append(std::strerror(errno)); > - throw std::runtime_error(err_msg); > + err_msg.append(std::strerror(errno)); > + throw std::runtime_error(err_msg); > } > } > + > + sigemptyset(&sig_mask); > + sigaddset(&sig_mask, SIGCHLD); > + sigprocmask(SIG_UNBLOCK, &sig_mask, NULL); > } > > bool xorg::testing::XServer::Terminate(unsigned int timeout) {
Everything looks reasonable to me. For the series: Reviewed-by: Chase Douglas <[email protected]> _______________________________________________ [email protected]: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
