This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: SYSTEMROOT, cygpath, and /proc funniness


Nellis, Kenneth wrote:
In .bash_profile I use cygpath to convert several environment variables that contain Windows paths to instead contain Unix paths. One in particular, SYSTEMROOT, has caused several problems, one of which is causing ClearCase's cleartool to be non-functional. Another is strictly within Cygwin itself where there seems to be some funny relationship between SYSTEMROOT, having the working directory be /proc, and the cygpath command.

The script, below, demonstrates the problem. It takes the
following options:
0: run with defaults
1: run with cd /proc
2: run with SYSTEMROOT cygpath'd
3: run with both options
-----
	I tried your script on my system and couldn't reproduce
the results.

I altered the script to run all cases in succession.

My results on all 4 cases (calling script with "test.sh all 3")
case=all, count=3
5572: old priority 0, new priority -19
 case = 0, PWD=/tmp, SYSTEMROOT=C:\Windows,
Iter 0 @ 10:51:30: 0.07sec 0.01usr 0.00sys (19.73% cpu)
Iter 0 @ 10:51:31: 0.07sec 0.01usr 0.00sys (19.23% cpu)
Iter 0 @ 10:51:32: 0.07sec 0.01usr 0.00sys (19.23% cpu)
 case = 1, PWD=/proc, SYSTEMROOT=C:\Windows,
Iter 1 @ 10:51:32: 0.08sec 0.00usr 0.03sys (37.80% cpu)
Iter 1 @ 10:51:33: 0.07sec 0.03usr 0.00sys (39.24% cpu)
Iter 1 @ 10:51:33: 0.08sec 0.00usr 0.01sys (18.75% cpu)
 case = 2, PWD=/tmp, SYSTEMROOT=/Windows,
Iter 2 @ 10:51:34: 0.08sec 0.00usr 0.00sys (0.00% cpu)
Iter 2 @ 10:51:35: 0.07sec 0.00usr 0.01sys (19.23% cpu)
Iter 2 @ 10:51:35: 0.07sec 0.01usr 0.01sys (38.46% cpu)
 case = 3, PWD=/proc, SYSTEMROOT=/Windows,
Iter 3 @ 10:51:36: 0.07sec 0.00usr 0.01sys (19.48% cpu)
Iter 3 @ 10:51:36: 0.07sec 0.00usr 0.03sys (41.33% cpu)
Iter 3 @ 10:51:37: 0.07sec 0.01usr 0.01sys (40.25% cpu)

Script:

#!/bin/bash
TIMEFORMAT="%2Rsec %2Uusr %2Ssys (%P%% cpu)"
case=-1
count=20

uname -a

function usage {
   echo "Usage: $0 {0|1|2|3|all}"
   exit 1
}

function _setup {
 local case=$1
 count=${2:-$count}
 #echo "_setup1: case=$case, count=$count"
 case $case in
     0)  ;;
     1)  cd /proc
   ;;
     2)  SYSTEMROOT=$(cygpath "$SYSTEMROOT")
   ;;
     3)  cd /proc
   SYSTEMROOT=$(cygpath "$SYSTEMROOT")
   ;;
    all)
   ;;
     *)  echo "$0: invalid parameter: $1"
   usage
   exit 1
   ;;
 esac
 echo "$case $count"
}

function do_test {
 case=$1
 use_count=$2
 echo "  case = $case, PWD=$PWD, SYSTEMROOT=$SYSTEMROOT, "
 for ((n=1; n<=use_count; n++)); do
     echo -n "Iter $1 @ $(date +'%H:%M:%S'): "
     time cygpath /proc &>/dev/null
     sleep 0.3
 done
}

#get case & count from initial setup
read case count<<< "$(_setup "$@")"
echo "case=$case, count=$count"
# try for highest priority to minimize other procs 'stealing' cpu cycles
renice -19 $$
if [[ $case != all ]] ;then
 do_test $case $count
elif [[ $case == all ]]; then
 for ((case=0; case<=3; ++case)); do
   # call setup before each 'do_test' to simulate original script and do
   #   each in a subshell to isolate any unanticipated side-effects
   (
     _setup $case $count &>/dev/null
     do_test $case $count
   )
 done
fi



--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]