From: Peng H. <pe...@cn...> - 2011-12-29 02:19:01
|
Cyril Hrubis said the following on 2011-12-28 19:54: >> Can you tell me a simple way to catch return value of background process? >> Thanks. > > See manual pages for jobs and wait. > Thanks for your suggest. I know wait, but I think wait is not better than catching error message. If you think wait is better, the following patch use wait. test_proc_kill() tests process will be killed due to exceed memory limit, but when memcg_process exit due to mmap/munmap fails, the case still pass. Signed-off-by: Peng Haitao <pe...@cn...> --- .../memcg/functional/memcg_function_test.sh | 13 +++++++++++-- 1 files changed, 11 insertions(+), 2 deletions(-) diff --git a/testcases/kernel/controllers/memcg/functional/memcg_function_test.sh b/testcases/kernel/controllers/memcg/functional/memcg_function_test.sh index 6bec8c1..dcfb49e 100755 --- a/testcases/kernel/controllers/memcg/functional/memcg_function_test.sh +++ b/testcases/kernel/controllers/memcg/functional/memcg_function_test.sh @@ -180,8 +180,17 @@ test_proc_kill() sleep 1 echo $pid > tasks - /bin/kill -s SIGUSR1 $pid 2> /dev/null - sleep 1 + { + sleep 2 + /bin/kill -s SIGUSR1 $pid 2> /dev/null + }& + + wait $pid + if [ $? -eq 1 ]; then + result $FAIL "process $pid is killed by error" + return + fi + ps -p $pid > /dev/null 2> /dev/null if [ $? -ne 0 ]; then result $PASS "process $pid is killed" -- 1.7.1 -- Best Regards, Peng |