bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

exit status issue


From: Dallas Clement
Subject: exit status issue
Date: Thu, 17 Nov 2011 16:03:46 -0600

Hello,

I've got a script that is periodically performing a disk / raid array
integrity check by touching a file.  The touch is failing
occasionally, with an exit status of 1.  If I do 'strace touch'
instead of just 'touch' the strace indicates an exit status of 0.  So
I'm not sure why this is getting propagated back as a 1 to the script.
  Would appreciate any insight you could offer.  Here is my script and
the strace output for when touch returns 1.

fsaccesstest()
{
        local RETRY_MAX=3
        local RETRY_INTERVAL=3
        local CHK_RESULT=1

        TMP=`grep $1 /proc/mounts|awk '{print $1}'`
        if [ "$TMP" != "" ]; then
                for i in `seq 1 ${RETRY_MAX}`
                do
                        touch $1/.accesstest
                        CHK_RESULT=$?
                        if [ ${CHK_RESULT} -eq 0 ] ; then
                                break
                        fi
                        echo "*** fsaccesstest test $1 failed: 
status=${CHK_RESULT}.
retrying... (${i}) ***"
                        sleep ${RETRY_INTERVAL}
                done
                if [ $CHK_RESULT -ne 0 ]; then
                        echo "*** fsaccess test $1 failed. ***" >/dev/console
                        ## try to remount it.  It may be busy, so retry if 
necessary.
                        for j in `seq 1 ${RETRY_MAX}`
                        do
                                umount -f -l $1 # Force a lazy unmount
                                CHK_RESULT=$?
                                if [ ${CHK_RESULT} -eq 0 ]; then
                                        break
                                fi
                                sleep ${RETRY_INTERVAL}
                        done
                        if [ ${CHK_RESULT} -eq 0 ]; then
                                mount $TMP $1
                                CHK_RESULT=$?
                                if [ ${CHK_RESULT} -ne 0 ]; then
                                        echo "*** fsaccesstest failed to mount 
$1. ***" >/dev/console
                                        return ${CHK_RESULT}
                                fi
                        else
                                echo "*** fsaccesstest failed to unmount $1. 
***" >/dev/console
                                return ${CHK_RESULT}
                        fi
                fi
                return 0
        fi
        return 1
}

execve("/bin/touch", ["touch", "/mnt/array1/.accesstest"],
["HOSTNAME=TS-2RVED8", "TERM=linux", "SHELL=/bin/sh",
"LIBRARY_PATH=/usr/lib:/usr/local"..., "HUSHLOGIN=FALSE", "USER=root",
"PATH=/bin:/sbin:/usr/bin:/usr/sb"..., "MAIL=/var/spool/mail/root",
"C_INCLUDE_PATH=/usr/include:/usr"..., "PWD=/root", "HOME=/root",
"SHLVL=2", "LOGNAME=root", "_=/usr/local/bin/strace"]) = 0
brk(0)                                  = 0x1702000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
0) = 0x7f4599150000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
0) = 0x7f459914f000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat(3, {st_dev=makedev(8, 162), st_ino=90088, st_mode=S_IFREG|0644,
st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=40,
st_size=19548, st_atime=2011/11/15-08:39:02,
st_mtime=2011/11/15-08:39:00, st_ctime=2011/11/15-08:39:01}) = 0
mmap(NULL, 19548, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f459914a000
close(3)                                = 0
open("/lib64/libcrypt.so.1", O_RDONLY)  = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\320\n\0"..., 832) = 832
fstat(3, {st_dev=makedev(8, 162), st_ino=285064, st_mode=S_IFREG|0755,
st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=48,
st_size=23096, st_atime=2011/11/15-08:10:31,
st_mtime=2010/06/29-12:51:27, st_ctime=2011/11/15-08:07:41}) = 0
mmap(NULL, 1257888, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3,
0) = 0x7f4598f03000
mprotect(0x7f4598f08000, 1044480, PROT_NONE) = 0
mmap(0x7f4599007000, 8192, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x4000) = 0x7f4599007000
mmap(0x7f4599009000, 184736, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f4599009000
close(3)                                = 0
open("/lib64/libm.so.6", O_RDONLY)      = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\360?\0\0"..., 832) = 832
fstat(3, {st_dev=makedev(8, 162), st_ino=285045, st_mode=S_IFREG|0755,
st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=1064,
st_size=538200, st_atime=2011/11/15-08:10:31,
st_mtime=2010/06/29-12:51:27, st_ctime=2011/11/15-08:07:41}) = 0
mmap(NULL, 1569000, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3,
0) = 0x7f4598d83000
mprotect(0x7f4598e01000, 1048576, PROT_NONE) = 0
mmap(0x7f4598f01000, 8192, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x7e000) = 0x7f4598f01000
close(3)                                = 0
open("/lib64/libc.so.6", O_RDONLY)      = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0`\333\1\0"..., 832) = 832
fstat(3, {st_dev=makedev(8, 162), st_ino=285057, st_mode=S_IFREG|0755,
st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=2616,
st_size=1331216, st_atime=2011/11/15-08:10:31,
st_mtime=2010/06/29-12:51:27, st_ctime=2011/11/15-08:07:41}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
0) = 0x7f4599149000
mmap(NULL, 2343048, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3,
0) = 0x7f4598b46000
mprotect(0x7f4598c7a000, 1044480, PROT_NONE) = 0
mmap(0x7f4598d79000, 20480, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x133000) = 0x7f4598d79000
mmap(0x7f4598d7e000, 16520, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f4598d7e000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
0) = 0x7f4599148000
arch_prctl(ARCH_SET_FS, 0x7f45991486f0) = 0
mprotect(0x7f4598d79000, 12288, PROT_READ) = 0
munmap(0x7f459914a000, 19548)           = 0
getuid()                                = 0
getpid()                                = 32127
utime("/mnt/array1/.accesstest", NULL)         = 0
exit_group(0)                           = ?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]