We find this happens often with steps like:
Or test steps that produce a lot of output.
The outcome is often that a job uses ~5GB of space until it hits our global 1h timeout, even though that step does not have that much output. It's definitely Jenkins spinning on repeating the last few ~100 lines, although the process has already returned.
As a workaround, if the above line is replaced with:
then we don't ever experience the hang.
But for test output that isn't ideal.
Note that this issue also happens if the command itself has a timeout:
It can still hang for an hour, spewing tons of logs that just repeat the last few pages.