Hi Paul,
Sorry for the late reply, I been out of the net for a while.
Youre right, I've already solved this problem by removing the static qualifier and everything runs OK.
My excuse is, the code was not mine and I was just porting it from NT to Solaris

.
Thanks for all the responses
and cheers!