|
|
#!/bin/sh |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src |
|
|
print_ver_ nohup |
|
|
|
|
|
|
|
|
nohup sh -c 'echo stdout; echo stderr 1>&2' 2>err || fail=1 |
|
|
|
|
|
|
|
|
|
|
|
if test -t 1; then |
|
|
test "$(cat nohup.out)" = stdout || fail=1 |
|
|
if test -t 0; then |
|
|
echo 'nohup: ignoring input and appending output to 'nohup.out'\' |
|
|
else |
|
|
echo 'nohup: appending output to 'nohup.out'\' |
|
|
fi >exp || framework_failure_ |
|
|
else |
|
|
|
|
|
test -f nohup.out && fail=1 |
|
|
if test -t 0; then |
|
|
echo 'nohup: ignoring input' >exp |
|
|
else |
|
|
rm -f exp |
|
|
fi || framework_failure_ |
|
|
fi |
|
|
echo 'stderr' >> exp || framework_failure_ |
|
|
|
|
|
compare exp err || fail=1 |
|
|
rm -f nohup.out err exp |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
nohup sh -c 'echo stdout; echo stderr 1>&2' >out || fail=1 |
|
|
if test -t 2; then |
|
|
test "$(cat out|tr '\n' -)" = stdout-stderr- || fail=1 |
|
|
else |
|
|
test "$(cat out|tr '\n' -)" = stdout- || fail=1 |
|
|
fi |
|
|
|
|
|
test -f nohup.out && fail=1 |
|
|
rm -f nohup.out err |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if test -w /dev/full && test -c /dev/full; then |
|
|
( |
|
|
|
|
|
|
|
|
|
|
|
test -c /dev/tty && >/dev/tty || exit 0 |
|
|
|
|
|
exec >/dev/tty |
|
|
test -t 1 || exit 0 |
|
|
returns_ 125 nohup echo hi 2> /dev/full || fail=1 |
|
|
test -f nohup.out || fail=1 |
|
|
compare /dev/null nohup.out || fail=1 |
|
|
rm -f nohup.out |
|
|
exit $fail |
|
|
) || fail=1 |
|
|
fi |
|
|
|
|
|
nohup no-such-command 2> err |
|
|
errno=$? |
|
|
if test -t 1; then |
|
|
test $errno = 127 || fail=1 |
|
|
|
|
|
test -f nohup.out || fail=1 |
|
|
|
|
|
compare /dev/null nohup.out || fail=1 |
|
|
fi |
|
|
|
|
|
cat <<\EOF > exp || framework_failure_ |
|
|
nohup: appending output to 'nohup.out' |
|
|
nohup: cannot run command 'no-such-command': No such file or directory |
|
|
EOF |
|
|
|
|
|
|
|
|
rm -f nohup.out err exp |
|
|
|
|
|
|
|
|
touch k; chmod 0 k |
|
|
nohup ./k 2> err |
|
|
errno=$? |
|
|
test $errno = 126 || fail=1 |
|
|
if test -t 1; then |
|
|
|
|
|
test -f nohup.out || fail=1 |
|
|
|
|
|
compare /dev/null nohup.out || fail=1 |
|
|
fi |
|
|
|
|
|
cat <<\EOF > exp || framework_failure_ |
|
|
nohup: appending output to 'nohup.out' |
|
|
nohup: cannot run command './k': Permission denied |
|
|
EOF |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
returns_ 125 nohup >/dev/null 2>&1 || fail=1 |
|
|
export POSIXLY_CORRECT=1 |
|
|
returns_ 127 nohup >/dev/null 2>&1 || fail=1 |
|
|
unset POSIXLY_CORRECT |
|
|
|
|
|
|
|
|
( |
|
|
rm -f nohup.out |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
test -c /dev/tty && >/dev/tty || exit 0 |
|
|
exec >/dev/tty |
|
|
test -t 1 || exit 0 |
|
|
|
|
|
umask 600 |
|
|
|
|
|
nohup echo hi || fail=1 |
|
|
test "$(stat -c %a nohup.out)" = 600 || fail=1 |
|
|
|
|
|
rm -f nohup.out |
|
|
exit $fail |
|
|
) || fail=1 |
|
|
|
|
|
Exit $fail |
|
|
|