Skip to content

stdbuf implementation via spawning is incompatible with coreutils #9066

Description

@allisonkarlitskaya

hi,

The GNU coreutils version of stdbuf are implemented by setting the LD_PRELOAD and other environment variables and then calling exec() on the requested command. This means that the command ends up having the PID that the parent expects it to and can be signalled. It also means PR_SET_PDEATHSIG affects the command in question.

The uutils replacement uses spawning (and collecting the return value and returning it) as an alternative but doesn't arrange to forward signals. Even if it did attempt to forward some signals, it could never forward SIGKILL, and PR_SET_PDEATHSIG also doesn't end up getting correctly set on the spawned process, because of the extra fork().

This has shown up as a failure in the CI of Cockpit as we attempt to adjust to the inclusion of uutils coreutils in the latest Ubuntu version.

In my opinion, the only way to fix this that's fully compatible with the existing GNU behaviour is to directly use exec() instead of forking. I understand that this is probably unsafe but I think it's necessary in this case...

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions