Conversation
|
@dirk-thomas I think I've implemented your suggestions but with one thing that seems like a bit of a hack--when the process is killed from SIGINT, task_state.returncode is -2, while |
|
For subprocesses the minus will come from here: https://docs.python.org/3/library/subprocess.html#subprocess.CompletedProcess.returncode I don't think the comparison should use |
|
I'm not sure we can do much better than checking the return codes defined in the https://github.com/ros2/launch/pull/27/files#diff-c102f8d6ec360dfe1b5780f069b1231cR100 |
|
I am arguing that we need to clarify what a return code can / should be. What values are the executables supposed to return in case of user error and signals. At least in the case where we want to test for signals we need to distinguish them. Based on your comment ("on Unix the return codes for tasks will always be negative") there should be no need for using |
|
I've updated the ignore_signal exit handler so that the return code is ignored if the process gets -SIGTERM on Windows or -SIGINT on Linux. The new exit handler is needed in ros2/rcl#48 to make the services test stable in rcl. I can also make a unit test for the exit handler in |
|
I wanted to point out that at the moment there's no problem since it doesn't use this exit handler, but if we decide it's best practice not to use return codes in a particular range, that's an example of a test that we should remember to update |
|
Why should |
|
According to several places in the code, sending https://github.com/ros2/launch/blob/master/launch/launch/launcher.py#L211-L222 |
|
The comment states that But launch/launch/launch/launcher.py Lines 246 to 255 in a33ebfe |
|
I thought about it some more and I think ignoring SIGTERM is OK. Feels like I'm running in circles... f318973 |
|
From discussion: It would be valuable to extend the API such that the handler will have additional information about whether the launcher sent a signal to the process so that if the SIGINT was sent from the launcher, it can be ignored. It would also be valuable to potentially change the RMW and RCL error enum values to deduplicate return/exit codes for the future. Pick number over at least the standard 15-20. Possibly reserve specific ranges for user return/exit codes. |
|
for reference, this is what I was referring to about there already being something checking if the process was in teardown in the ros2/examples |
|
The With the additional information mentioned above it will be possible to more granular decide if the return code of the other processes should override the return code of launch. |
|
eaf87de is a start for making the logic of this exit handler a bit smarter, adding a To make it even more granular I could record which signal was sent to terminate the process (e.g. SIGINT or SIGKILL). |
|
The boolean flag doesn't allow to filter the return code in the error handler yet. Please record a list of signals which have been sent to the process instead. |
launch/launch/exit_handler.py
Outdated
| if task_state.terminated_from_launch: | ||
| sigint_received = signal.SIGINT in context.task_state.signals_received | ||
| sigterm_received = signal.SIGTERM in context.task_state.signals_received | ||
| if sigint_received or sigterm_received: |
There was a problem hiding this comment.
Why not replace the three lines with if p.task_state.signals_received:?
There was a problem hiding this comment.
I guess I wrote it like this to be extra specific in case we end up sending more signals to tasks in the future. But I guess it's okay to say that the ignore_signal_exit_handler is for ignoring all kinds of signals sent to the task by launch.
|
ok, in 7882939 the new field is changed to |
|
I made a branch in rcl with the same name as this one that is identical to ros2/rcl#48 and launched CI: http://ci.ros2.org/job/ci_linux/1238/ |
bb29765 to
b2d05b5
Compare
|
rebuilding after merge conflict was resolved http://ci.ros2.org/job/ci_linux/1239/ |
|
The pyflakes failure in CI is fixed in 65a957c. |
|
Any thoughts on the current state of |
|
lgtm |
Add coverage on 0% covered files
This is needed for the C services tests. To test remote services, the service process must stick around until the client receives a response from the service. Rather than introducing signal handling in the rcl tests, we will instead make the service process block forever and use the exit handler introduced by this PR to ignore only SIGINT or SIGTERM in the service process when it is interrupted. I opted not to use the ignore all return codes exit handler in case there are other errors in the service handler.