delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2011/04/28/13:58:00

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-0.9 required=5.0 tests=AWL,BAYES_00,TW_YG,T_RP_MATCHES_RCVD
X-Spam-Check-By: sourceware.org
Message-ID: <4DB9AA83.9080300@tlinx.org>
Date: Thu, 28 Apr 2011 10:57:23 -0700
From: Linda Walsh <cygwin AT tlinx DOT org>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.24) Thunderbird/2.0.0.24 Mnenhy/0.7.6.666
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: SYSTEMROOT, cygpath, and /proc funniness
References: <2BF01EB27B56CC478AD6E5A0A28931F20262E742 AT A1DAL1SWPES19MB DOT ams DOT acs-inc DOT net>
In-Reply-To: <2BF01EB27B56CC478AD6E5A0A28931F20262E742@A1DAL1SWPES19MB.ams.acs-inc.net>
X-Stationery: 0.5.1
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019