rupprecht updated this revision to Diff 457631. rupprecht added a comment. - Use pthread_kill to only kill the current thread
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D133181/new/ https://reviews.llvm.org/D133181 Files: lldb/unittests/Host/MainLoopTest.cpp Index: lldb/unittests/Host/MainLoopTest.cpp =================================================================== --- lldb/unittests/Host/MainLoopTest.cpp +++ lldb/unittests/Host/MainLoopTest.cpp @@ -32,17 +32,13 @@ ASSERT_TRUE(error.Success()); Socket *accept_socket; - std::future<Status> accept_error = std::async(std::launch::async, [&] { - return listen_socket_up->Accept(accept_socket); - }); - std::unique_ptr<TCPSocket> connect_socket_up( new TCPSocket(true, child_processes_inherit)); error = connect_socket_up->Connect( llvm::formatv("localhost:{0}", listen_socket_up->GetLocalPortNumber()) .str()); ASSERT_TRUE(error.Success()); - ASSERT_TRUE(accept_error.get().Success()); + ASSERT_TRUE(listen_socket_up->Accept(accept_socket).Success()); callback_count = 0; socketpair[0] = std::move(connect_socket_up); @@ -174,7 +170,7 @@ auto handle = loop.RegisterSignal(SIGUSR1, make_callback(), error); ASSERT_TRUE(error.Success()); - kill(getpid(), SIGUSR1); + pthread_kill(pthread_self(), SIGUSR1); ASSERT_TRUE(loop.Run().Success()); ASSERT_EQ(1u, callback_count); } @@ -192,14 +188,9 @@ auto handle = loop.RegisterSignal(SIGUSR1, make_callback(), error); ASSERT_TRUE(error.Success()); - std::thread killer([]() { - sleep(1); - kill(getpid(), SIGUSR2); - sleep(1); - kill(getpid(), SIGUSR1); - }); + pthread_kill(pthread_self(), SIGUSR2); + pthread_kill(pthread_self(), SIGUSR1); ASSERT_TRUE(loop.Run().Success()); - killer.join(); ASSERT_EQ(1u, callback_count); } @@ -220,7 +211,7 @@ SIGUSR1, [&](MainLoopBase &loop) { ++callback2_count; }, error); ASSERT_TRUE(error.Success()); - kill(getpid(), SIGUSR1); + pthread_kill(pthread_self(), SIGUSR1); ASSERT_TRUE(loop.Run().Success()); ASSERT_EQ(1u, callback_count); ASSERT_EQ(1u, callback2_count); @@ -233,7 +224,7 @@ SIGUSR1, [&](MainLoopBase &loop) { ++callback3_count; }, error); ASSERT_TRUE(error.Success()); - kill(getpid(), SIGUSR1); + pthread_kill(pthread_self(), SIGUSR1); ASSERT_TRUE(loop.Run().Success()); ASSERT_EQ(2u, callback_count); ASSERT_EQ(1u, callback2_count); @@ -241,7 +232,7 @@ } // Both extra callbacks should be unregistered now. - kill(getpid(), SIGUSR1); + pthread_kill(pthread_self(), SIGUSR1); ASSERT_TRUE(loop.Run().Success()); ASSERT_EQ(3u, callback_count); ASSERT_EQ(1u, callback2_count);
Index: lldb/unittests/Host/MainLoopTest.cpp =================================================================== --- lldb/unittests/Host/MainLoopTest.cpp +++ lldb/unittests/Host/MainLoopTest.cpp @@ -32,17 +32,13 @@ ASSERT_TRUE(error.Success()); Socket *accept_socket; - std::future<Status> accept_error = std::async(std::launch::async, [&] { - return listen_socket_up->Accept(accept_socket); - }); - std::unique_ptr<TCPSocket> connect_socket_up( new TCPSocket(true, child_processes_inherit)); error = connect_socket_up->Connect( llvm::formatv("localhost:{0}", listen_socket_up->GetLocalPortNumber()) .str()); ASSERT_TRUE(error.Success()); - ASSERT_TRUE(accept_error.get().Success()); + ASSERT_TRUE(listen_socket_up->Accept(accept_socket).Success()); callback_count = 0; socketpair[0] = std::move(connect_socket_up); @@ -174,7 +170,7 @@ auto handle = loop.RegisterSignal(SIGUSR1, make_callback(), error); ASSERT_TRUE(error.Success()); - kill(getpid(), SIGUSR1); + pthread_kill(pthread_self(), SIGUSR1); ASSERT_TRUE(loop.Run().Success()); ASSERT_EQ(1u, callback_count); } @@ -192,14 +188,9 @@ auto handle = loop.RegisterSignal(SIGUSR1, make_callback(), error); ASSERT_TRUE(error.Success()); - std::thread killer([]() { - sleep(1); - kill(getpid(), SIGUSR2); - sleep(1); - kill(getpid(), SIGUSR1); - }); + pthread_kill(pthread_self(), SIGUSR2); + pthread_kill(pthread_self(), SIGUSR1); ASSERT_TRUE(loop.Run().Success()); - killer.join(); ASSERT_EQ(1u, callback_count); } @@ -220,7 +211,7 @@ SIGUSR1, [&](MainLoopBase &loop) { ++callback2_count; }, error); ASSERT_TRUE(error.Success()); - kill(getpid(), SIGUSR1); + pthread_kill(pthread_self(), SIGUSR1); ASSERT_TRUE(loop.Run().Success()); ASSERT_EQ(1u, callback_count); ASSERT_EQ(1u, callback2_count); @@ -233,7 +224,7 @@ SIGUSR1, [&](MainLoopBase &loop) { ++callback3_count; }, error); ASSERT_TRUE(error.Success()); - kill(getpid(), SIGUSR1); + pthread_kill(pthread_self(), SIGUSR1); ASSERT_TRUE(loop.Run().Success()); ASSERT_EQ(2u, callback_count); ASSERT_EQ(1u, callback2_count); @@ -241,7 +232,7 @@ } // Both extra callbacks should be unregistered now. - kill(getpid(), SIGUSR1); + pthread_kill(pthread_self(), SIGUSR1); ASSERT_TRUE(loop.Run().Success()); ASSERT_EQ(3u, callback_count); ASSERT_EQ(1u, callback2_count);
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits