Creating sub windows

I’m trying to create a sub window using glutCreateSubWindow. When I run the program it just flickers on for a split second and then ends ! The subwindow is being created because I can see it for that split second. For the first parameter in glutCreateSubWindow I’m using the return value from glutCreateWindow.
Any suggestions???
Thanks in advance.