Redirecting stdout problem

I have a simple bash script that prints sth every 5 seconds. What I do is the following. I redirect the output of the script to a file, tail the file and see that it works and then from another console I delete the file where the output is redirected to. Even though I have deleted the file, the tail still works. Stoping the tail and starting it again of course fails because the file is not found.
My question is whether this is normal and does the output go "somewhere" after deleting the file where it is supposed to be redirected.

Best,
Iliya

The file still exists until everything with it open, closes it or quits.

Try truncating it, i.e. overwriting it with nothing, instead of deleting it. Having it open can't prevent that from happening, and tail -f is usually smart enough to seek back to the beginning.

: > filename

Yes,
the open file descriptors that refer to the deleted file remain (there will be an unnamed file).

Consider the following example (this is on Linux):

zsh-4.3.17[t]% zsh -c 'while :; do sleep 3;date ; done > outfile'&
[1] 1470
zsh-4.3.17[t]% ls -l /proc/1470/fd
total 0
lrwx------ 1 drado drado 64 Jun 20 23:08 0 -> /dev/pts/2
l-wx------ 1 drado drado 64 Jun 20 23:08 1 -> /home/drado/t/outfile
lrwx------ 1 drado drado 64 Jun 20 23:08 10 -> /dev/pts/2
lr-x------ 1 drado drado 64 Jun 20 23:08 11 -> /dev/null
lrwx------ 1 drado drado 64 Jun 20 23:08 12 -> /dev/pts/2
lrwx------ 1 drado drado 64 Jun 20 23:08 2 -> /dev/pts/2
zsh-4.3.17[t]% tail -f /home/drado/t/outfile
Wed Jun 20 23:08:08 CEST 2012
Wed Jun 20 23:08:11 CEST 2012
Wed Jun 20 23:08:14 CEST 2012
Wed Jun 20 23:08:17 CEST 2012
Wed Jun 20 23:08:20 CEST 2012
Wed Jun 20 23:08:23 CEST 2012
^C
zsh-4.3.17[t]% rm /home/drado/t/outfile
zsh-4.3.17[t]% tail -f /home/drado/t/outfile
tail: cannot open `/home/drado/t/outfile' for reading: No such file or directory
zsh-4.3.17[t]% tail -f /proc/1470/fd/1
Wed Jun 20 23:08:14 CEST 2012
Wed Jun 20 23:08:17 CEST 2012
Wed Jun 20 23:08:20 CEST 2012
Wed Jun 20 23:08:23 CEST 2012
Wed Jun 20 23:08:26 CEST 2012
Wed Jun 20 23:08:29 CEST 2012
Wed Jun 20 23:08:32 CEST 2012
Wed Jun 20 23:08:35 CEST 2012
Wed Jun 20 23:08:39 CEST 2012
Wed Jun 20 23:08:42 CEST 2012
Wed Jun 20 23:08:45 CEST 2012
^C
zsh-4.3.17[t]% lsof -p1470|fgrep outf
zsh     1470 drado    1w   REG  252,0      630  261137 /home/drado/t/outfile (deleted)
zsh-4.3.17[t]% kill -9 %1
zsh-4.3.17[t]%
[1]  + killed     zsh -c 'while :; do sleep 3;date ; done > outfile'