| 1 |
#!/bin/bash |
| 2 |
|
| 3 |
# This file is part of util-linux. |
| 4 |
# |
| 5 |
# This file is free software; you can redistribute it and/or modify |
| 6 |
# it under the terms of the GNU General Public License as published by |
| 7 |
# the Free Software Foundation; either version 2 of the License, or |
| 8 |
# (at your option) any later version. |
| 9 |
# |
| 10 |
# This file is distributed in the hope that it will be useful, |
| 11 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
# GNU General Public License for more details. |
| 14 |
|
| 15 |
TS_TOPDIR="${0%/*}/../.." |
| 16 |
TS_DESC="all_processes" |
| 17 |
|
| 18 |
. "$TS_TOPDIR/functions.sh" |
| 19 |
ts_init "$*" |
| 20 |
|
| 21 |
ts_skip_nonroot |
| 22 |
|
| 23 |
# make sure we do not use shell built-in command |
| 24 |
if [ "$TS_USE_SYSTEM_COMMANDS" == "yes" ]; then |
| 25 |
TS_CMD_KILL="$(which kill)" |
| 26 |
fi |
| 27 |
|
| 28 |
ts_check_test_command "$TS_CMD_KILL" |
| 29 |
ts_check_test_command "$TS_HELPER_SIGRECEIVE" |
| 30 |
|
| 31 |
. "$TS_SELF/kill_functions.sh" |
| 32 |
|
| 33 |
HELPER_SYMLINK="$(mktemp "${TS_OUTDIR}/alXXXXXXXXXXXXX")" |
| 34 |
ln -sf "$TS_HELPER_SIGRECEIVE" "$HELPER_SYMLINK" |
| 35 |
|
| 36 |
"$HELPER_SYMLINK" -s "$TS_TESTUSER" >> $TS_OUTPUT 2>> $TS_ERRLOG & |
| 37 |
TEST_PID=$! |
| 38 |
|
| 39 |
check_test_sigreceive $TEST_PID |
| 40 |
[ $? -eq 1 ] || echo "${HELPER_SYMLINK##*/} helper did not start" >> "$TS_OUTPUT" |
| 41 |
|
| 42 |
|
| 43 |
ts_log_both "test 1" |
| 44 |
"$TS_CMD_KILL" ${HELPER_SYMLINK##*/} >> $TS_OUTPUT 2>> $TS_ERRLOG |
| 45 |
if [ $? -ne 1 ]; then |
| 46 |
echo "kill did not return 1" >> "$TS_OUTPUT" |
| 47 |
fi |
| 48 |
|
| 49 |
ts_log_both "test 2" |
| 50 |
"$TS_CMD_KILL" -a ${HELPER_SYMLINK##*/} >> $TS_OUTPUT 2>> $TS_ERRLOG |
| 51 |
if [ $? -ne 0 ]; then |
| 52 |
echo "kill did not return 0" >> "$TS_OUTPUT" |
| 53 |
fi |
| 54 |
wait $TEST_PID |
| 55 |
|
| 56 |
ts_log_both "test 3" |
| 57 |
"$TS_CMD_KILL" -a -p ${HELPER_SYMLINK##*/} >> $TS_OUTPUT 2>> $TS_ERRLOG |
| 58 |
if [ $? -ne 1 ]; then |
| 59 |
echo "kill -a -p did not return 1" >> "$TS_OUTPUT" |
| 60 |
fi |
| 61 |
|
| 62 |
sed -i "s/${HELPER_SYMLINK##*/}/${TS_HELPER_SIGRECEIVE##*/}/" $TS_OUTPUT $TS_ERRLOG |
| 63 |
|
| 64 |
rm -f "$HELPER_SYMLINK" |
| 65 |
|
| 66 |
ts_finalize |