When a container is killed by its AM we get a similar error message like this:
In container-executor.c the fork point is right after the "Creating script paths..." part, though in the Stdout log we can clearly see it has been written there twice. After consulting with Peter Bacsko it seems like there's a missing flush in container-executor.c before the fork and that causes the duplication.
I suggest to add a flush there so that it won't be duplicated: it's a bit misleading that the child process writes out "Getting exit code file" and "Creating script paths" even though it is clearly not doing that.
A more appealing solution could be to revisit the fprintf-fflush pairs in the code and change them to a single call, so that the fflush calls would not be forgotten accidentally. (It can cause problems in every place where it's used).
Note: this issue probably affects every occasion of fork(), not just the one from launch_container_as_user in main.c.