I have found that understanding the WHY of the behaviour helps to prevent me becoming frustrated/upset at what they are doing. It is a bit like when a baby cries in pain - it isn't irritating in the slightest, all you want to do is fix it for them, and you cry a little bit inside at your inability to fix it immediately. That empathy that you feel communicates to them, and they find solace in your presence.
With a child who has experienced what I posted above, it is important to help them make their new world make sense; to show them that THIS is how it should be. THIS is the order they were looking for. THIS is normal life. It is also important to give them an outlet for their confusion. So explaining everything to start with, ESPECIALLY if you are upset about something. You have a child with no normal frame of reference. Every time you are upset, they do not know if you'll spiral into uncontrollable anger, how long it will last, or what you will do. They could never see a pattern in what upset their carer before, you need to show them the pattern, and help them understand your emotions. From there, they can begin to understand their own. Explain what has upset you, how you're feeling, what you're doing about it, the lot.
xx sweetheart, Mummy has lost her keys. Have you seen them? Ok, I'll just look for them (take deep breath!). You can come with me and look if you want. I am worried because we need to find them so we can take the dog for her walk. I am sure they are here somewhere! Where did I last see them? I think I had them when I brought the shopping in for the car. Let's go and look in the kitchen. (if LO has come in with you - I'm looking in the bags we had, if you want to help you could look in the cupboard where I put the crisps...). Keep verbalizing your thoughts, keep as calm as you can, until you find them. If LO has come to help, you don't want to scare them, but it would be really good for them if they could feel they had the power to change things, to help you look, and then, once you spot them (e.g. next to your shoes, in the hall) you could pretend you haven't seen them, ask LO to look there, and let THEM find them. Lots of praise for finding them, and a cuddle.
It is about re-training their expectations, showing them what a normal emotional response to each situation is, helping them to understand that behaviour and what they can do about it. Even you articulating, 'I'm worried about xx so I'm going to take a deep breath and count to ten to calm myself down,' provides reassurance (you do know how to calm down so won't explode on them) and a model for their own emotional responses.
They need to find their new pattern and know what to predict. So ground rules that are explicitly set out, with explicit consequences for undesirable actions are fantastic. You need to be very careful of their past experiences when devising those consequences (as previous posters have mentioned!), but it helps to set a frame of reference for their daily life with you. The initial reactions to any consequence can be rather dramatic, but as soon as the consequence has happened, you need to be totally over whatever they did, all smiley and happy and yourself again. Then they know that the consequence ends there. That's it.
Equally, some behaviours stem from them copying their previous carers. They may think it is an act of love to tell someone they will kill them, for example, or to hit. Their minds are so confused, that you need to explain carefully and lovingly, why a behaviour is not desirable, and what it does to the recipient. That said, a total, out of control tantrum is best left to burn itself out somewhere safe. We used to leave the room when one child started throwing chairs. Once he'd stopped, then was time to explain what he had done, to get him to help clear it up, to give him reassurance that we didn't hate him for it. That trigger was found pretty quickly, but it triggered such extreme emotions in one so young, that he literally could not control them. Having choices helped another child. "You can do this with me now, do it on your own, or do it with me later." They had some control over their own life for the first time ever.
When working with animals (so much simpler!) it has taken 3-6 months for them to totally relax and trust ME. Anything up to 3 years though for them to trust that others will react as I do, to learn to control their own emotions appropriately and for their true personalities to show through. Often the most aggressive/extreme behaviours stem from the most sweet, generous and giving personalities. The hurt is far deeper. That said though, one of the horses I rehabilitated (she was beaten as a training method and came terrified and aggressive) now works at a centre for traumatised children from that sort of background. She has an amazing empathy for them and is totally trustworthy, whatever they do.