Executing shell commands from Library Component

I have created a library component with a non-rt worker thread.
Within that thread i want to call the curl binary using fork() … exec(„curl“, …).
Strangely it sometimes works as expected but other times it either immediately returns without executing curl or indefinately freezes.
Is there something special within plcnext that i need to take care of?

I discovered that this behavior was a result of me overeagerly logging error messages with (i.e. Log::Error("...")) from within the forked process. I suspect that lead to either a crash or waiting on resources that the main process owns and will never free.
After removing any logging from the critical section, everything went as expected.
Thanks to Tim Rohmann of Phoenix Contact, who has pointed out to me that an alternative would have been to use libcurl, which apparently is contained in the PLCnext SDK.

Tim may have also mentioned that, if the worker thread is running in the same process as the PLCnext Runtime, then forking that process will fork the entire PLCnext Runtime process, which is known to cause problems. It’s advisable to not fork that process, e.g. by running custom components in a separate process.