From 8d297e07c113adf255547d2900c338a23f360f61 Mon Sep 17 00:00:00 2001 From: Chris Freehill Date: Sun, 9 Aug 2020 18:59:23 -0500 Subject: [PATCH] Fix how test deals with terminating rdcd Previously we would return -1 if we detected rdcd was still running. But the rdcd process ID is alive as long as the test is running. So now we return 0, and the rdcd process ends, allowing the test to end cleanly. Change-Id: I98a5aa0a03d14127824b86e1190047c9f9d2edb7 [ROCm/rdc commit: 15be17539f9dcc716b295bad0c44e4b7a04683e2] --- projects/rdc/tests/rdc_tests/main.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/projects/rdc/tests/rdc_tests/main.cc b/projects/rdc/tests/rdc_tests/main.cc index ed7674bc3c..312c72ed37 100755 --- a/projects/rdc/tests/rdc_tests/main.cc +++ b/projects/rdc/tests/rdc_tests/main.cc @@ -158,17 +158,17 @@ static int killRDCD(int pid = 0) { } // Try several times; it may take some time for rdcd to clean up. for (int i = 0; i < 20; ++i) { - sleep(1); + sleep(0.01); pid = getPIDFromName("rdcd"); if (pid == -1) { return 0; } + ret = kill(pid, SIGTERM); } - std::cout << "ERROR: Failed to kill existing rdcd instance." << std::endl; - return -1; + return 0; } static int startRDCD(std::string *rdcd_path, char *envp[]) { @@ -178,7 +178,9 @@ static int startRDCD(std::string *rdcd_path, char *envp[]) { if (pid == 0) { if (-1 == execve(rdcd_cl[0], (char **)rdcd_cl , envp)) { // NOLINT - perror("ERROR: Child process failed to start rdcd"); + std::string err_msg = "ERROR: Child process failed to start "; + err_msg += *rdcd_path; + perror(err_msg.c_str()); return -1; } }