kfdtest: Fix the dead lock SignalHandling

The issue arises in the CatchSignal function, which attempts to write to
the standard error stream upon receiving a signal. However, the standard
error stream may already be locked at this point, as the parent process
also attempts to write to the standard error stream after mapping the GPU
memory. This leads to a deadlock, with the program waiting for the
release of the lock on the standard error stream.

Signed-off-by: Emily Deng <Emily.Deng@amd.com>
Change-Id: Ie69354f4342b96ffe1f2a87f655687da1cbee4b9
Cette révision appartient à :
Emily Deng
2024-11-21 17:53:03 +08:00
Parent 09b899b079
révision c8031f2a69
+8 -2
Voir le fichier
@@ -1468,9 +1468,10 @@ TEST_F(KFDMemoryTest, PtraceAccessInvisibleVram) {
TEST_END
}
volatile int IntrSignalReceviced;
void CatchSignal(int IntrSignal) {
LOG() << "Interrupt Signal " << std::dec << IntrSignal
<< " Received" << std::endl;
IntrSignalReceviced = IntrSignal;
}
TEST_F(KFDMemoryTest, SignalHandling) {
@@ -1529,6 +1530,11 @@ TEST_F(KFDMemoryTest, SignalHandling) {
// Parent process, just wait for the child to finish
do {
pid = waitpid(childPid, &childStatus, 0);
if (IntrSignalReceviced) {
LOG() << "Interrupt Signal " << std::dec << IntrSignalReceviced
<< " Received" << std::endl;
IntrSignalReceviced = 0;
}
} while(pid == -1 && errno == EINTR);
EXPECT_EQ(childPid, pid);
EXPECT_NE(0, WIFEXITED(childStatus));