problem with exit while using nohup

Hi,

I am kinda confused with this, am not sure what is happening

i have a script say test.sh
----------

cat myfile | while read line
do
exit 2
done

echo "out of loop"

-----------

as it is evident, the exit should cause the script to terminate ,hence producing no output for the script.

now when i run the script as "./test.sh", the behaviour is as expected.
but when i run it with nohup as "nohup ./test.sh &", the "out of loop" statement appears in the output, indicating that the exit just gets it outside the loop but does not exit the program.

any ideas on this ?

Strange!

On HP-UX it behaves the same way for me with or without nohup, exiting before the end of the loop.

On Linux it always displays 'out of loop', with or without nohup.

On Solaris it behaves as you describe... however if I add a #!/usr/bin/ksh shebang line it behaves the way you would expect (i.e. like HP-UX). So it seems to be a feature of the Solaris Bourne shell. Is that what you are using?