Skip to content

Forward SIGTERM to child process #237

Description

@alyssaruth

What

We have a .NET app which is wrapped in the codecoverage tool in our local development stack, like this:

exec /app/tools/dotnet-coverage collect --session-id "coverage-session" -f cobertura -o "/tmp/coverage/coverage-$(basename "${DLL_NAME}").xml" -- dotnet "$DLL_NAME" "$@"

Inside this application we have a service which hooks into the IHostApplicationLifetime interface to register an action on ApplicationStopping:

// Register shutdown
_hostApplicationLifetime.ApplicationStopping.Register(OnStopping);

However, when running the app wrapped in codecoverage, our OnStopping doesn't fire. That's because codecoverage itself ends up being PID 1 inside the container, and it doesn't pass the SIGTERM signal on to our own application:

$ ps -aux
USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
app            1  0.3  0.3 6180692 218940 ?      Ssl  14:30   0:03 /app/tools/dotnet-coverage collect --session-id coverage-session -f cobertura -o /tmp/coverage/coverage-app.dll.xml -- dotnet /app/app.dll
app           17  0.4  0.3 8401572 242552 ?      Sl   14:30   0:03 dotnet /app/app.dll

Proposed solution

codecoverage should pass on any kill signals it gets to the process that it's wrapping, and wait for the child process to terminate before terminating itself.

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

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions