This is the mail archive of the cygwin@sources.redhat.com 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]

Re: newbie: Out of order execution in script


I guess I'm confused as to why one should expect things exec'd to run in 
a certain sequence.  Isn't that the point of execing?  If you're going to 
start 2 processes yet expect one to do something before the other needs it,
you need to make sure the processes synchronize themselves.  Obviously, this
synchronization is not happening here or in Art's example AFAICT.  Why do
you expect to see synchronization here?

Larry


At 03:04 PM 11/22/2000, Randall R Schulz wrote:
>Hi,
>
>I've got an analogous problem under Windows 2000 Pro SP1. The problem began occurring in previously working BASH function when I upgraded to Cygwin 1.1.5. It is still happening in 1.1.6.
>
>Here's the shell function definition whose "side-effects" on the file ".logon" occur out of order:
>
>logon() {
>         if [ -n "$(jobs)" ]; then
>                 echo "There are stopped jobs." >&2
>                 return 1
>         fi
>
>         cd
>         echo "#!/bin/sh" >|.logon
>         cat  .env-initial >>.logon
>         echo "exec /bin/bash --login -i" >> .logon
>         exec -lc .logon
>}
>
>After running this function the "exec /bin/bash --login -i" line is the second line in the file (the #! line comes first). Here are the first few lines of ".logon" after the logon function is executed:
>
>-==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==-
>#!/bin/sh
>exec /bin/bash --login -i
>ALLUSERSPROFILE="C:\\Documents and Settings\\All Users"
>APPDATA="C:\\Documents and Settings\\Randall R Schulz\\Application Data"
>CLASSPATH="C:\\WINNT\\System32\\QTJava.zip"
>COMMONPROGRAMFILES="C:\\Program Files\\Common Files"
>COMPUTERNAME="CLEMENS"
>COMSPEC="C:\\WINNT\\system32\\cmd.exe"
>-==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==-
>
>My mail server is spam-blocked (wrongly) so only Larry and Art are going to see this mail.
>
>I'd like to help resolve this. If you have anything you'd like me to do to help diagnose the underlying problem, let me know. I've attached a file containing "cygcheck -s -v" output.
>
>RandyS
>
>
>At 13:48 -0500 11/22/00, schwarza@gdls.com wrote:
>>I have rechecked the results and do not believe that this is
>>a Win95 issue.
>>
>>The following modified code was executed (bash -x <script> 2>&1 | tee
>><file>
>>
>>     [0] Statements prior to execution of [1]
>>
>>     [1] ${importScript} ${importMain} ${tmp}
>>
>>     [2] if [ ! -e ${outImp}.imp ] ; then
>>
>>     [3]     echo 'ERROR: Unable to find ' ${outImp}.imp
>>
>>     [4]    exit
>>
>>         fi
>>
>>     [5] sed -e '/(/d'                             \
>>             -e 's@/kostabi@@'                     \
>>             -e 's@^@\ -aI/kostabi@'               \
>>             -e 's@/@\\@g'           ${outImp}.imp > ${gnatI}
>>
>>
>>
>>It appears that:
>>
>>    [1] Was forked.
>>
>>    [2] Was immediately executed.
>>
>>    [3] Was sequentially executed.
>>
>>    [4] Was sequentially executed and the intermediate output for
>>        [1] was dumped.
>>
>>    [5] Was not executed.
>>
>>If I guessed correctly, the fork proceeded in parallel to the main
>>script execution. All output (echo) from the forked script was placed
>>into a temporary file. The 'echo' in the calling script generated an
>>out-of-order output. When the calling script 'exit' was executed, the
>>intermediate output stored for the called script was dumped. The trace
>>output is included below.
>>
>>Am I looking at this the wrong way?
>>
>>
>>art
>>---------------------------------------------------------------------
>>
>>[0] + echo 'Start processing ' device_control_main  ## executing called
>>script
>>[0]   Start processing  device_control_main
>>[0] + echo
>>/aaav/aaav/MPA/build/device_control/devices.ss/aaav_scm_mpa.rel/device_control_main.adb
>>[0] + /aaav/scripts/import.sh /tmp/386107.gnatmake/import.txt
>>/tmp/386107.gnatmake
>>
>>###  at this time the called script seems to be executing
>>
>>[2] + '[' '!' -e /tmp/386107.gnatmake/device_control_main.imp ']'
>>[3] + echo 'ERROR: Unable to find '
>>/tmp/386107.gnatmake/device_control_main.imp
>>[3] ERROR: Unable to find  /tmp/386107.gnatmake/device_control_main.imp
>>[4] + exit
>>
>>[1] Main file:  device_control_main
>>[1] /aaav/aaav/MPA/build/device_control/devices.ss/aaav_scm_mpa.rel
>>[1] ... more output
>>
>>
>>
>>--
>>Want to unsubscribe from this list?
>>Send a message to cygwin-unsubscribe@sourceware.cygnus.com
>
>



--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com


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