Index: pcp/man/man1/pmsleep.1 =================================================================== --- pcp.orig/man/man1/pmsleep.1 2007-07-02 15:33:26.988523000 +1000 +++ pcp/man/man1/pmsleep.1 2007-07-02 15:33:27.180523000 +1000 @@ -35,7 +35,11 @@ for and in the simplest form may be an unsigned integer or floating point constant (the implied units in this case are seconds). - -.PP +.SH DIAGNOSTICS The exit status is 0 for success, or 1 for a malformed command line. -If the underlying nanosleep fails, an errno is returned. +If the underlying +.B nanosleep (2) +system call fails, an errno is returned. +.SH SEE ALSO +.BR sleep (1), +.BR nanosleep (3). Index: pcp/src/pmcd/rc_pcp =================================================================== --- pcp.orig/src/pmcd/rc_pcp 2007-07-02 15:33:27.036523000 +1000 +++ pcp/src/pmcd/rc_pcp 2007-07-02 15:38:31.376523000 +1000 @@ -117,8 +117,6 @@ in ;; esac -SLEEPCMND="$PCP_BINADM_DIR/pmsleep 0.1" - _pmcd_logfile() { default=$RUNDIR/pmcd.log @@ -403,28 +401,16 @@ _shutdown() $PCP_KILLALL_PROG -TERM pmcd > /dev/null 2>&1 fi $ECHO $PCP_ECHO_N "Waiting for PMCD to terminate ...""$PCP_ECHO_C" - gone=0 - i=0 - j=0 - while : + delay=200 # tenths of a second + while [ $delay -gt 0 ] do _get_pids_by_name pmcd >$tmp.tmp - if [ ! -s $tmp.tmp ] - then - gone=1 - break - fi - i=`expr $i + 1` - if [ $i -ge 10 ] - then - i=0 - [ $j -ge $delay ] && break - j=`expr $j + 1` - $ECHO $PCP_ECHO_N ".""$PCP_ECHO_C" - fi - $SLEEPCMND + [ ! -s $tmp.tmp ] && break + pmsleep 0.1 + delay=`expr $delay - 1` + [ `expr $delay % 10` -ne 0 ] || $ECHO $PCP_ECHO_N ".""$PCP_ECHO_C" done - if [ $gone != 1 ] # It just WON'T DIE, give up. + if [ $delay -eq 0 ] # It just WON'T DIE, give up. then echo "Process ..." cat $tmp.tmp Index: pcp/src/pmsleep/pmsleep.c =================================================================== --- pcp.orig/src/pmsleep/pmsleep.c 2007-07-02 15:33:27.168523000 +1000 +++ pcp/src/pmsleep/pmsleep.c 2007-07-02 15:33:27.212523000 +1000 @@ -13,7 +13,6 @@ main(int argc, char **argv) { struct timespec rqt; struct timeval delta; - int r = 0; char *msg; if (argc == 2) { @@ -23,13 +22,11 @@ main(int argc, char **argv) } else { rqt.tv_sec = delta.tv_sec; rqt.tv_nsec = delta.tv_usec * 1000; - if (0 != nanosleep(&rqt, NULL)) - r = errno; - - exit(r); + return (nanosleep(&rqt, NULL) == 0) ? 0 : errno; } + } else { + fprintf(stderr, "Usage: pmsleep \n"); } - fprintf(stderr, "Usage: pmsleep [-v] interval\n"); exit(1); /*NOTREACHED*/ } Index: pcp/src/pmie/pmie_check.sh =================================================================== --- pcp.orig/src/pmie/pmie_check.sh 2007-07-02 15:33:27.072523000 +1000 +++ pcp/src/pmie/pmie_check.sh 2007-07-02 15:33:27.228523000 +1000 @@ -31,8 +31,6 @@ PMIE=pmie -SLEEPCMND="$PCP_BINADM_DIR/pmsleep 0.1" - # added to handle problem when /var/log/pcp is a symlink, as first # reported by Micah_Altman@xxxxxxxxxxx in Nov 2001 # @@ -177,15 +175,13 @@ _lock() { # demand mutual exclusion # - fail=true rm -f $tmp.stamp - i=0 - while : + delay=200 # tenths of a second + while [ $delay -ne 0 ] do if pmlock -v $logfile.lock >$tmp.out then echo $logfile.lock >$tmp.lock - fail=false break else if [ ! -f $tmp.stamp ] @@ -199,12 +195,11 @@ _lock() rm -f $logfile.lock fi fi - [ $i -ge 200 ] && break #tenths of a sec - $SLEEPCMND - i=`expr $i + 1` + pmsleep 0.1 + delay=`expr $delay - 1` done - if $fail + if [ $delay -eq 0 ] then # failed to gain mutex lock # @@ -311,10 +306,8 @@ _check_pmie() # wait for maximum time of a connection and 20 requests # - delay=`expr $delay + 20 \* $x` - i=0 - j=0 - while : + delay=`expr \( $delay + 20 \* $x \) \* 10` # tenths of a second + while [ $delay -ne 0 ] do if [ -f $logfile ] then @@ -327,7 +320,7 @@ _check_pmie() then : else - $SLEEPCMND + pmsleep 0.1 $VERBOSE && echo " done" return 0 fi @@ -365,15 +358,10 @@ _check_pmie() return 1 fi fi - i=`expr $i + 1` - if [ $i -ge 10 ] - then - i=0 - [ $j -ge $delay ] && break - j=`expr $j + 1` - $VERBOSE && $PCP_ECHO_PROG $PCP_ECHO_N ".""$PCP_ECHO_C" - fi - $SLEEPCMND + pmsleep 0.1 + delay=`expr $delay - 1` + $VERBOSE && [ `expr $delay % 10` -eq 0 ] && \ + $PCP_ECHO_PROG $PCP_ECHO_N ".""$PCP_ECHO_C" done $VERBOSE || _message restart echo " timed out waiting!" @@ -681,14 +669,14 @@ then then $VERY_VERBOSE && ( echo; $PCP_ECHO_PROG $PCP_ECHO_N "+ $KILL -KILL `cat $tmp.pmies` ...""$PCP_ECHO_C" ) eval $KILL -KILL $pmielist >/dev/null 2>&1 - i=0 + delay=30 # tenths of a second while ps -f -p "$pmielist" >$tmp.alive 2>&1 do - if [ $i -lt 30 ] + if [ $delay -gt 0 ] then - $SLEEPCMND - i=`expr $i + 1` - continue; + pmsleep 0.1 + delay=`expr $delay - 1` + continue fi echo "$prog: Error: pmie process(es) will not die" cat $tmp.alive Index: pcp/src/pmlogctl/pmlogger_check.sh =================================================================== --- pcp.orig/src/pmlogctl/pmlogger_check.sh 2007-07-02 15:33:27.088523000 +1000 +++ pcp/src/pmlogctl/pmlogger_check.sh 2007-07-02 15:33:27.244523000 +1000 @@ -68,8 +68,6 @@ then PWDCMND=/bin/pwd fi -SLEEPCMND="$PCP_BINADM_DIR/pmsleep 0.1" - # default location # logfile=pmlogger.log @@ -211,10 +209,8 @@ _check_logger() # wait for maximum time of a connection and 20 requests # - delay=`expr $delay + 20 \* $x` - i=0 - j=0 - while : + delay=`expr \( $delay + 20 \* $x \) \* 10` # tenths of a second + while [ $delay -gt 0 ] do if [ -f $logfile ] then @@ -226,7 +222,7 @@ _check_logger() then : else - $SLEEPCMND + pmsleep 0.1 $VERBOSE && echo " done" return 0 fi @@ -263,15 +259,10 @@ _check_logger() return 1 fi fi - i=`expr $i + 1` - if [ $i -ge 10 ] - then - i=0 - [ $j -ge $delay ] && break - j=`expr $j + 1` - $VERBOSE && $PCP_ECHO_PROG $PCP_ECHO_N ".""$PCP_ECHO_C" - fi - $SLEEPCMND + pmsleep 0.1 + delay=`expr $delay - 1` + $VERBOSE && [ `expr $delay % 10` -eq 0 ] && \ + $PCP_ECHO_PROG $PCP_ECHO_N ".""$PCP_ECHO_C" done $VERBOSE || _message restart echo " timed out waiting!" @@ -403,10 +394,9 @@ s/^\([A-Za-z][A-Za-z0-9_]*\)=/export \1; else # demand mutual exclusion # - fail=true rm -f $tmp.stamp - i=0 - while : + delay=200 # tenths of a second + while [ $delay -gt 0 ] do if pmlock -v lock >$tmp.out then @@ -434,12 +424,11 @@ s/^\([A-Za-z][A-Za-z0-9_]*\)=/export \1; rm -f lock fi fi - [ $i -ge 200 ] && break #tenths of a sec - $SLEEPCMND - i=`expr $i + 1` + pmsleep 0.1 + delay=`expr $delay - 1` done - if $fail + if [ $delay -eq 0 ] then # failed to gain mutex lock #