Re: [PATCH xorg-gtest] Wait for dummy X server to shut down in Environment::TearDown()
On 04/20/2012 05:39 PM, Stephen M. Webb wrote: On 04/20/2012 12:45 PM, Chase Douglas wrote: If two xorg-gtest binaries are executed one after another, the second one may attempt to start its X server before the first one's X server has fully shut down. This leads to the second X server not starting. Signed-off-by: Chase Douglas chase.doug...@canonical.com Reviewd-by: Stephen M. Webb stephen.w...@bregmasoft.ca Thanks! I've applied all four reviewed patches to master. 1e7618f..6b66ce9 -- Chase ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
[PATCH xorg-gtest] Wait for dummy X server to shut down in Environment::TearDown()
If two xorg-gtest binaries are executed one after another, the second one may attempt to start its X server before the first one's X server has fully shut down. This leads to the second X server not starting. Signed-off-by: Chase Douglas chase.doug...@canonical.com --- src/environment.cpp | 30 -- 1 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/environment.cpp b/src/environment.cpp index c1c4d80..d7d1c82 100644 --- a/src/environment.cpp +++ b/src/environment.cpp @@ -144,17 +144,35 @@ void xorg::testing::Environment::SetUp() { } void xorg::testing::Environment::TearDown() { - if (!d_-process.Terminate()) { -std::cerr Warning: Failed to terminate dummy Xorg server: - std::strerror(errno) \n; -if (!d_-process.Kill()) - std::cerr Warning: Failed to kill dummy Xorg server: - std::strerror(errno) \n; + if (d_-process.Terminate()) { +for (int i = 0; i 10; i++) { + int status; + int pid = waitpid(d_-process.Pid(), status, WNOHANG); + + if (pid == d_-process.Pid()) +return; + + sleep(1); /* Give the dummy X server more time to shut down */ +} } + + Kill(); } void xorg::testing::Environment::Kill() { if (!d_-process.Kill()) std::cerr Warning: Failed to kill dummy Xorg server: std::strerror(errno) \n; + + for (int i = 0; i 10; i++) { +int status; +int pid = waitpid(d_-process.Pid(), status, WNOHANG); + +if (pid == d_-process.Pid()) + return; + + sleep(1); /* Give the dummy X server more time to shut down */ + } + + std::cerr Warning: Dummy X server did not shut down\n; } -- 1.7.9.1 ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
Re: [PATCH xorg-gtest] Wait for dummy X server to shut down in Environment::TearDown()
On 04/20/2012 12:45 PM, Chase Douglas wrote: If two xorg-gtest binaries are executed one after another, the second one may attempt to start its X server before the first one's X server has fully shut down. This leads to the second X server not starting. Signed-off-by: Chase Douglas chase.doug...@canonical.com Reviewd-by: Stephen M. Webb stephen.w...@bregmasoft.ca --- src/environment.cpp | 30 -- 1 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/environment.cpp b/src/environment.cpp index c1c4d80..d7d1c82 100644 --- a/src/environment.cpp +++ b/src/environment.cpp @@ -144,17 +144,35 @@ void xorg::testing::Environment::SetUp() { } void xorg::testing::Environment::TearDown() { - if (!d_-process.Terminate()) { -std::cerr Warning: Failed to terminate dummy Xorg server: - std::strerror(errno) \n; -if (!d_-process.Kill()) - std::cerr Warning: Failed to kill dummy Xorg server: - std::strerror(errno) \n; + if (d_-process.Terminate()) { +for (int i = 0; i 10; i++) { + int status; + int pid = waitpid(d_-process.Pid(), status, WNOHANG); + + if (pid == d_-process.Pid()) +return; + + sleep(1); /* Give the dummy X server more time to shut down */ +} } + + Kill(); } void xorg::testing::Environment::Kill() { if (!d_-process.Kill()) std::cerr Warning: Failed to kill dummy Xorg server: std::strerror(errno) \n; + + for (int i = 0; i 10; i++) { +int status; +int pid = waitpid(d_-process.Pid(), status, WNOHANG); + +if (pid == d_-process.Pid()) + return; + + sleep(1); /* Give the dummy X server more time to shut down */ + } + + std::cerr Warning: Dummy X server did not shut down\n; } -- Stephen M. Webb stephen.w...@bregmasoft.ca signature.asc Description: OpenPGP digital signature ___ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel