It turns out that this happens when the process is started as a child of another process. I was testing this by running the project in my IDE. When I actually ran the executable manually it worked as expected. A weird quirk that doesn't seem to be documented anywhere.