[CRIU] [PATCH 1/3] tests: replace cat in Makefiles with awk

Vitaly Ostrosablin vostrosablin at virtuozzo.com
Mon Nov 28 00:51:00 PST 2016


Sorry, my bad. I've got things mixed up and I've misdescribed the problem in commit message. In fact, problem was opposite to that. pidfiles actually contain no newlines. As seen in test.c, pids are written like that:

dprintf(fd, "%d", pid)

Hence, "cat *.pid" would produce a single undelimited string of numbers, like 1000110002100031000410005... and kill would obviously fail. It's possible to modify test.c instead to print newline after the pid. Then we would have no need to modify Makefiles. I used awk to print pids separated instead, to avoid editing the zdtm lib.


________________________________
От: Pavel Emelianov
Отправлено: 25 ноября 2016 г. 17:59
Кому: Cyrill Gorcunov; crml
Копия: Vitaly Ostrosablin; Andrey Vagin
Тема: Re: [CRIU] [PATCH 1/3] tests: replace cat in Makefiles with awk

On 11/25/2016 05:19 PM, Cyrill Gorcunov wrote:
> From: Vitaly Ostrosablin <vostrosablin at virtuozzo.com>
>
> cat outputs pidfiles with newlines at end,
> while we need them to be unsplitted for kill
> command to work.

What's the environment in which kill doesn't work with \n-s?

> Signed-off-by: Vitaly Ostrosablin <vostrosablin at virtuozzo.com>
> Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
> ---
>  test/zdtm/static/Makefile     | 4 ++--
>  test/zdtm/transition/Makefile | 4 ++--
>  2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/test/zdtm/static/Makefile b/test/zdtm/static/Makefile
> index 6d8cd755fe22..4bafc10e373a 100644
> --- a/test/zdtm/static/Makefile
> +++ b/test/zdtm/static/Makefile
> @@ -342,7 +342,7 @@ start:    $(PID) $(STATE)
>  check_start: $(PID:%.pid=%.is_running)
>
>  stop:        $(STATE_OUT)
> -     -kill -TERM `cat *.pid`
> +     -kill -TERM `awk '{print}' *.pid`
>
>  WAIT_TIME=240
>  %.stop:      %.pid %
> @@ -360,7 +360,7 @@ WAIT_TIME=240
>  wait_stop:
>                i=0; \
>                while [ $$i -lt $(WAIT_TIME) ] ; do \
> -             kill -0 `cat *.pid 2>/dev/null` 2>/dev/null || break; \
> +             kill -0 `awk '{print}' *.pid 2>/dev/null` 2>/dev/null || break; \
>                sleep 1; \
>                i=`expr $$i + 1`; \
>        done
> diff --git a/test/zdtm/transition/Makefile b/test/zdtm/transition/Makefile
> index 8e82070f81e5..a5ca99fa215f 100644
> --- a/test/zdtm/transition/Makefile
> +++ b/test/zdtm/transition/Makefile
> @@ -65,12 +65,12 @@ start:    $(PID)
>  check_start: $(PID:%.pid=%.is_running)
>
>  stop:
> -     -kill -TERM `cat *.pid`
> +     -kill -TERM `awk '{print}' *.pid`
>
>  WAIT_TIME=10
>  wait_stop:
>        -for i in `seq 1 $(WAIT_TIME)`; do \
> -             kill -0 `cat *.pid 2>/dev/null` 2>/dev/null || break; \
> +             kill -0 `awk '{print}' *.pid 2>/dev/null` 2>/dev/null || break; \
>                sleep 1; \
>        done
>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openvz.org/pipermail/criu/attachments/20161128/c678be38/attachment.html>


More information about the CRIU mailing list