#72 Redirection of output causes console hang

closed
nobody
None
8
2006-09-13
2006-06-20
Anonymous
No

I'm running a batch file via "cmd.exe /K xxx.bat" with
Console v2. The batch file performs several output
redirections to temporary files. This causes Console
v2 to hang and the cmd.exe uses 100% of the CPU. This
problem does not exist in Console v1.5.

rstephenson_68@yahoo.com

Discussion

  • Logged In: YES
    user_id=16767

    Can you attach your batch file, or some minimal generic .bat
    file that reproduces the problem?

    I already had this kind of bug reported, but I was unable to
    reproduce it...

     
  • Logged In: NO

    I can send you the batch file if you like. It changes the
    way the cd command works; it makes it behave a little more
    like a unix cd. It's rather large so it might be better if
    I email it to you?

    Also, I viewed the hidden windows console when the lock up
    occurs, and the windows console still works fine. It's just
    the V2 console that's hung.

    Thanks!

     
  • Logged In: YES
    user_id=16767

    Please attach the file here. Thanks.

     
  • Logged In: NO

    Here is the batch file. I don't know how to attach it as a
    file (sorry). I usually alias this to the cd command within
    a doskey macro.

    BTW, I downloaded beta 121 and I haven't experienced the
    problem yet. Maybe this has been fixed?

    Thanks for the great program!

    @echo off
    :: ***NOTE: MAKE SURE THAT THIS FILE IS INSTALLED SOMEWHERE
    IN THE PATH***
    :: Author: Ron Stephenson
    :: Date: 8/4/2000
    :: Updated on 8/5/2000 to work on Windows 95/98 (and
    hopefully DOS)
    :: Usage notes: Works like normal cd plus accepts "-" and
    "~" explained below
    ::
    :: This batch program allows the user to change directories
    in a better
    :: fashion by allowing the use of a "-" for changing back to
    a previous
    :: directory. This is very helpful when a person needs to
    jump back and
    :: forth between two directories. This program also accepts
    a "~" input
    :: parameter to change to the user's "HOME" directory (this
    is a UNIX thing
    :: that I always liked.) Finally, it also changes the title
    of the command
    :: window to show the current directory. This allows the
    user to change
    :: his/her command prompt to not show the current directory.
    (This only
    :: works on Windows NT/2000. Finally, this program also
    allows drives to
    :: be used when changing directories (e.g. cd d:\games)
    ::
    ***********************************************************************

    :: Blank the title first to avoid seeing a flash of the
    batch file name being
    :: executed (this does not work on Windows 95/98, of course)
    if not "%OS%"=="" set WINVER="NT"
    if not "%WINVER%"=="" TITLE
    :: I have seen a case where find fails, but grep works fine,
    so if grep
    :: is present, I use it instead of find.
    set search=find
    if exist C:\cygwin\bin\grep.exe set search=grep

    :: Set the path variable to have the temp directory in it.
    :: We will restore the path when finished.
    PATH>%temp%.\respath.bat
    PATH %temp%;%path%
    set src=%temp%
    set INPUTS=%1 %2 %3 %4 %5 %6 %7 %8 %9
    set currdrv=C
    set prevdrv=%currdrv%

    :: Store the previous directory
    ::
    *******************************************************************
    :: * The way this works is to create a bat file called
    directory which
    :: * will be executed from go.bat which has a line in it
    :: * similar to the following: Directory of C:\Bin. We then
    pass the
    :: * second through last parameters to the cd command and voila!
    ::
    *******************************************************************
    dir /AD/W/-P . | %search% "Directory">%src%.\go.bat
    echo @echo off >%src%.\directory.bat
    echo set currdir=%%2 %%3 %%4 %%5 %%6 %%7 %%8
    %%9>>%src%.\directory.bat
    for %%c in (call del) do %%c %src%.\go.bat
    :: Delete any unneeded files
    del %src%.\directory.bat > nul

    :: If this is the first run for this cmd prompt, there is no
    previous directory,
    :: so make the current directory the previous one to start with
    if "%prevdir%"=="" set prevdir=%currdir%
    :: Store the previous drive letter (Win95/98)
    if "%WINVER%"=="" echo %prevdir%
    |CHOICE.COM/N/Ccdefghijklmnopqrstuvwxyz0123456789\.........~
    set prevdrv=> %temp%.\prevdrvl.bat
    if "%WINVER%"=="" FOR %%c in (CALL DEL) do %%c
    %temp%.\prevdrvl.bat

    :: Try something for ~\directory
    echo %1 | %search% "~">%src%.\try.dat
    dir /w %src%.\try.dat | find /I "File">%src%.\go2.bat
    echo @echo off >%src%.\1.bat
    echo set fsize=%%2 >>%src%.\1.bat
    for %%c in (call del) do %%c %src%.\go2.bat
    for %%c in (%src%.\1.bat %src%.\try.dat) do del %%c

    :: I'm using parens instead of quotes. Works even when %1
    is already surrounded
    :: by quotes
    if (%1)==() goto normal
    if (%1)==(-) goto backup
    if (%1)==(~) goto home
    :: Yet another thing that 95 can't do; big surprise
    if not "%WINVER%"=="" if not "%fsize%"=="0 " goto home

    :: Change directories normally
    :: ===========================
    :normal
    :: Store the current drive letter (Win95/98)
    if "%WINVER%"=="" echo %1
    |CHOICE.COM/N/Ccdefghijklmnopqrstuvwxyz0123456789\.........~
    set currdrv=> %temp%.\currdrvl.bat
    if "%WINVER%"=="" FOR %%c in (CALL DEL) do %%c
    %temp%.\currdrvl.bat
    :: I can't figure out how to check if currdrv is valid, so
    just hide errors for now
    if "%WINVER%"=="" CTTY nul
    if "%WINVER%"=="" %currdrv%:
    if "%WINVER%"=="" CTTY con
    if "%WINVER%"=="" cd %INPUTS%
    :: The drive junk above is not needed on NT/2000. Just use
    the /D switch
    if not "%WINVER%"=="" cd /D%*
    :: Get the name of the directory that we just changed to so
    we can set the
    :: window title appropriately. We do this in the same way
    that we did when
    :: we stored the previous directory earlier
    dir /AD/W/-P | %search% "Directory">%src%.\go.bat
    echo @echo off >%src%.\directory.bat
    echo set title=%%2 %%3 %%4 %%5 %%6 %%7 %%8
    %%9>>%src%.\directory.bat
    for %%c in (call del) do %%c %src%.\go.bat
    :: Delete any unneeded files
    %src%.\directory.bat > nul
    goto end

    :: Change to your home directory
    :: =============================
    :home
    :: This should be set to whatever the user wants for his/her
    home directory
    :: It can also use an environment variable called HOME
    if "%HOME%"=="" set HOME=C:\ :: Store the current drive letter (Win95/98)
    if "%WINVER%"=="" echo %HOME%
    |CHOICE.COM/N/Ccdefghijklmnopqrstuvwxyz0123456789\.........~
    set currdrv=> %temp%.\currdrvl.bat
    if "%WINVER%"=="" FOR %%c in (CALL DEL) do %%c
    %temp%.\currdrvl.bat
    if "%WINVER%"=="" %currdrv%:
    if "%WINVER%"=="" cd %HOME%
    if not "%WINVER%"=="" cd /D %HOME%
    set title=%HOME%
    goto end

    :: Change to the previous directory
    :: ================================
    :backup
    if "%WINVER%"=="" %prevdrv%:
    if "%WINVER%"=="" cd %prevdir%
    if not "%WINVER%"=="" cd /D %prevdir%
    set title=%prevdir%
    goto end

    :end
    :: Save the previous directory for later use and set the
    window title to show
    :: the name of the current directory. Also clear any
    unneeded env variables and
    :: restore the original path
    :: =========================
    if not "%WINVER%"=="" Title %title%
    set prevdir=%currdir%
    set currdir=
    set currdrv=
    set rec=
    set src=
    set INPUTS=
    set search=
    set fsize=
    FOR %%C IN (CALL DEL) DO %%C %temp%.\respath.bat

     
  • Logged In: NO

    I just experienced the problem again on beta 121, so it
    seems that the problem still exists.

    Regards,

    Ron

     
  • Logged In: YES
    user_id=16767

    Beta 121, or 122? 121 didn't address this issue.

     
  • Atomhrt
    Atomhrt
    2006-07-06

    Logged In: YES
    user_id=1026237

    It may well be fixed in 122! I could usually make this
    happen very easily with prior builds, especially when I did
    not adjust the refresh settings. No problems with either
    redirection or my infamous bat file with version 122. I
    will let you know if I see any problems, but so far, so
    good! :)

     
  • Atomhrt
    Atomhrt
    2006-07-06

    Logged In: YES
    user_id=1026237

    It may well be fixed in 122! I could usually make this
    happen very easily with prior builds, especially when I did
    not adjust the refresh settings. No problems with either
    redirection or my infamous bat file with version 122. I
    will let you know if I see any problems, but so far, so
    good! :)

     
  • Logged In: YES
    user_id=16767

    That would be great. I'll make one change in 123 that might
    break this again... Keep an eye on it :)

     
  • Atomhrt
    Atomhrt
    2006-07-08

    Logged In: YES
    user_id=1026237

    Your gonna break it in 123? Don't you dare! Just kidding...
    I will keep 122 around just in case. But yes, I will
    definitely be keeping an eye on it! I gave it quite a work-
    out already with no issues, but next week it should get an
    even greater work-out. THANKS, btw for fixing this, it was
    a BIG problem and kind of a show stopper for me and would
    be for anyone really using console in earnest.

     
    • priority: 5 --> 8
     
  • Logged In: YES
    user_id=16767

    It seems this issue has been fixed. Closing.

     
    • status: open --> closed