[CRIU] [PATCH] parasite-syscall: describe task's state on trap failure
Andrew Vagin
avagin at virtuozzo.com
Thu Jun 9 13:41:48 PDT 2016
Acked-by: Andrew Vagin <avagin at virtuozzo.com>
On Thu, Jun 09, 2016 at 02:56:50PM +0300, Dmitry Safonov wrote:
> I think we can improve error messages to distinguish task's kills
> from segfaults from ptrace failures & etc.
>
> Signed-off-by: Dmitry Safonov <dsafonov at virtuozzo.com>
> ---
> criu/parasite-syscall.c | 28 ++++++++++++++++++++++------
> 1 file changed, 22 insertions(+), 6 deletions(-)
>
> diff --git a/criu/parasite-syscall.c b/criu/parasite-syscall.c
> index f9e0bac7ffbf..e8e31fb2da4a 100644
> --- a/criu/parasite-syscall.c
> +++ b/criu/parasite-syscall.c
> @@ -934,6 +934,26 @@ static int parasite_fini_seized(struct parasite_ctl *ctl)
> return 0;
> }
>
> +static bool task_is_trapped(int status, pid_t pid)
> +{
> + if (WIFSTOPPED(status) && WSTOPSIG(status) == SIGTRAP)
> + return true;
> +
> + pr_err("Task %d is in unexpected state: %x\n", pid, status);
> + if (WIFEXITED(status))
> + pr_err("Task exited with %d\n", WEXITSTATUS(status));
> + if (WIFSIGNALED(status))
> + pr_err("Task signaled with %d: %s\n",
> + WTERMSIG(status), strsignal(WTERMSIG(status)));
> + if (WIFSTOPPED(status))
> + pr_err("Task stopped with %d: %s\n",
> + WSTOPSIG(status), strsignal(WSTOPSIG(status)));
> + if (WIFCONTINUED(status))
> + pr_err("Task continued\n");
> +
> + return false;
> +}
> +
> /*
> * Trap tasks on the exit from the specified syscall
> *
> @@ -957,10 +977,8 @@ int parasite_stop_on_syscall(int tasks, const int sys_nr, enum trace_flags trace
> return -1;
> }
>
> - if (!WIFSTOPPED(status) || WSTOPSIG(status) != SIGTRAP) {
> - pr_err("Task is in unexpected state: %x\n", status);
> + if (!task_is_trapped(status, pid))
> return -1;
> - }
>
> pr_debug("%d was trapped\n", pid);
>
> @@ -996,10 +1014,8 @@ int parasite_stop_on_syscall(int tasks, const int sys_nr, enum trace_flags trace
> return -1;
> }
>
> - if (!WIFSTOPPED(status) || WSTOPSIG(status) != SIGTRAP) {
> - pr_err("Task is in unexpected state: %x\n", status);
> + if (!task_is_trapped(status, pid))
> return -1;
> - }
>
> pr_debug("%d was stopped\n", pid);
> tasks--;
> --
> 2.8.3
>
> _______________________________________________
> CRIU mailing list
> CRIU at openvz.org
> https://lists.openvz.org/mailman/listinfo/criu
More information about the CRIU
mailing list