diff --git a/launch/launch/actions/execute_process.py b/launch/launch/actions/execute_process.py index dbdb90886..eaa4372a1 100644 --- a/launch/launch/actions/execute_process.py +++ b/launch/launch/actions/execute_process.py @@ -766,7 +766,8 @@ async def __execute_process(self, context: LaunchContext) -> None: )) await context.emit_event(ProcessExited(returncode=returncode, **process_event_args)) # respawn the process if necessary - if not context.is_shutdown and not self.__shutdown_future.done() and self.__respawn: + if not context.is_shutdown and not self.__shutdown_future.done() and self.__respawn and \ + returncode != 0: if self.__respawn_delay is not None and self.__respawn_delay > 0.0: # wait for a timeout(`self.__respawn_delay`) to respawn the process # and handle shutdown event with future(`self.__shutdown_future`) diff --git a/launch/test/launch/test_execute_process.py b/launch/test/launch/test_execute_process.py index bfbcd069d..9a422dbdb 100644 --- a/launch/test/launch/test_execute_process.py +++ b/launch/test/launch/test_execute_process.py @@ -152,7 +152,7 @@ def generate_launch_description(): return LaunchDescription([ ExecuteProcess( - cmd=[sys.executable, '-c', "print('action')"], + cmd=[sys.executable, '-c', "import sys; print('action'); sys.exit(1)"], respawn=True, respawn_delay=respawn_delay, on_exit=on_exit_callback ),