diff --git a/pendulum_control/package.xml b/pendulum_control/package.xml
index f5ccba852..9dbb1995c 100644
--- a/pendulum_control/package.xml
+++ b/pendulum_control/package.xml
@@ -25,6 +25,7 @@
launch
launch_testing
rmw_implementation_cmake
+ ros2run
ament_cmake
diff --git a/pendulum_control/test/execute_with_delay.py b/pendulum_control/test/execute_with_delay.py
index 27fe28b1f..e2c1e7ade 100755
--- a/pendulum_control/test/execute_with_delay.py
+++ b/pendulum_control/test/execute_with_delay.py
@@ -13,10 +13,11 @@
# limitations under the License.
import argparse
-import subprocess
import sys
import time
+from ros2run.api import run_executable
+
def main():
parser = argparse.ArgumentParser(description='Delay and execute an executable.')
@@ -27,7 +28,8 @@ def main():
delay_time = args.delay * 0.001
time.sleep(delay_time)
- return subprocess.call(args.executable)
+ # use ros2run api to handle KeyboardInterrupt
+ return run_executable(path=args.executable[0], argv=args.executable[1:])
if __name__ == '__main__':