in reply to function or something

This, however, doesn't work. An error is still printed to stdout and the program colapses on itself.
"An error"? What error? Providing details like that can really help others help you. Also, I suspect the error went to stderr, not stdout.