Sorry to hear you're struggling. Intrusive thoughts are difficult enough when you're alone, and I can imagine that having them while you're with your child is very distressing.
Intrusive thoughts are fueled by our resistance to them. That's why the only thoughts that tend to stick around are ones that are distressing.
The sad feelings you're experiencing (which you mentioned in your other post), are probably just your response to these thoughts in the presence of your child. Your brain is sending signals to your body that it is in danger, even though it isn't, which can cause all sorts of complicated emotions, especially when you're around loved ones.
In reality, these thoughts you are experiencing are just thoughts. They can't hurt you, they can't make you do anything, and they don't mean anything about you. Thoughts don't predict the future and they aren't proof of any particular desires.
The ultimate goal is not to remove these thoughts, but to change your relationship to them. Think of them like suggestions from the subconscious regions of the brain, not as facts. Instead of getting worked up over thoughts or images of suicide, respond with, "that isn't useful to me right now, but thank you for the suggestion."
You can also respond with something like:
"Yes that might be so (as in, yes maybe I want to kill myself), and it might not be."
I know it sounds terrifying to even consider agreeing with these thoughts, but you might be surprised just how much weight they shed when you respond in this way, rather than "GO AWAY!"
As a parent, maybe it would be helpful to imagine these thoughts as a distraught child trying to get your attention, crying about something that they're worried about, like a monster under their bed. Rather than ignore the child, or get angry that they are upset, you can say, "I hear you, I see that you're upset, and that's okay."
You can have that same relationship with your thought.
In addition to this, be conscious of how you're breathing. Try to make your out-breaths longer (at least twice as long) as your in-breaths. This will help sooth your nervous system. That, in conjunction with your soften approach to these thoughts, should be extremely helpful over time. It takes practice.