microsoft / microsoft/codecoverage

Forward SIGTERM to child process

Open
#237 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
125
Forks
17
Avg merge
1h 17m
Merged PRs (30d)
2

Description

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the codecoverage command entry point and the process-launching path that runs the wrapped dotnet child; no source file or test is named in the issue. Done means the child receives termination signals and the wrapper waits for it to terminate.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
cli, devtools
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.