We've been experiencing this incredibly odd situation of late. DD age 3 is receiving chemo and has become friends with a boy age 5. He was expected to last for a few weeks, but it is now 9 weeks since being told the cancer was terminal. Every time we see the parents, we have a quick hug and a 'see you when we see you' type chat as we know they will leave the hospital once he has died. I don't think he has been specifically told he will die - which is fine, that is the parent's choice - but I would be surprised if he hasn't worked it out himself. OUR choice has to be completely honest with both our DD and her brother about what is happening to her.
We have spent a lot of time talking with this boy's parents and other parents and all agree saying nothing is the worst thing that you can do. Even saying 'I am really sorry, I don't know what to say' is enough. I would also add that it is unhelpful to say 'I don't know how you are coping' because the reality is they have no choice to deal with things in any way different to how they are.
I think you should break down what you can do into three time frames: now, immediately after death and the longer term.
For now, you just need to continue providing practical and emotional support. Anything domestic will be forgotten so just making sure you drop food off at home or hospital for them will help. Small, frequest contact works for us: texts rather than phonecalls (they know you are thinking about them but can call you when they need you rather than a call intruding on what might be a difficult time).
Ask them if they mind you visiting hospital to spend time with them as a family: even if the child is out of it on morphine, it is just nice to spend time holding hands, reading, just be a reassuring presence. And you can sit with the child whilst they go off to shower or eat - something they will be reluctant to do. If you are a trusted friend and they are reassured you will get them if anything happens, that might help.
Prior to/immediately after: depends on how the parents are, but I know our friends have been comforted by being able to exert some control over the funeral arrangements (the only control they have in a frighteningly uncontrollable time). Don't be afraid to talk about the inevitable and offer practical support for the arrangements. I felt so helpless hearing about our friends, I went and bought them a picture frame to help fill the house with photos, a bottle to toast his life and a candle. The candle was part of a private joke with the mum but also so that their home smelt very different from the last hours of their child (antiseptic wash, hospitals, medicines, illness etc). Both mum and dad said all three appreciated.
After: I am no expert on bereavement but my brief experience is that you may have to accept them pushing you away in the immediate aftermath as the constant stream of cards and messages (which will becoms a comfort in the future) are exhausting. Sure if you google 'grief cycle' or read the bereavement threads you will get a simple overview of the various stages of the bereavement cycle. I've found the macmillan and clic sragent sites helpful. From what I recollect of supporting DH when his mum died in quite tragic circumstances, the friends who continued to make small frequent contact were the most helpful, especially on key dates. One friend warned us that the second anniversary/xmas etc were the hardest as people had remembered the first, but the second kind of caught them bereaved out.
That is a bit of a brain dump for now but I hope it helps. Your friends will have to prepare themselves for a whole gamut of emotions, some of which are expected, some not. I know our friends are now at the stage when death will be a relief and they are already anticipating the guilt that will follow that emotion. Hard, really hard.