Skip to content

Unable to obtain target process exit code on Linux/Mac with CoreCLR debugging services #43731

Description

@gregg-miskelly

Description

On Linux/Mac the exit code of the target process is obtained through waitpid (Linux docs, Apple docs, PAL code that makes use of it). However, unlike on Windows -- if multiple places in a process are calling waitpid, unless the WNOWAIT flag is used (which doesn't seem to exist OSX), then my understanding is that this will prevent other callers from obtaining the exit code.

The debugging services open a HANDLE to the target process (as expected) through the PAL, which means that they may wind up 'owning' the exit code of the target process, but they don't, at least as far as I know, wind up propagating this exit code to the debugger.

The potential fixes I can think of are:

  1. Add a new 'managed callback' interface with another version of the ExitProcess method which provides the exit code to the debugger if the debugging services were able to obtain it.
    -or-
  2. Make changes to the PAL (ex: new fake access right to indicate that waitpid should be used) and opt-into them with the debugging services to avoid 'owning' the exit code. Thus the calling debugger can reliably use waitpid to obtain the exit code.

Regression?

No, this has never worked on Linux/Mac

Activity

  1. removed
    untriagedNew issue has not been triaged by the area owner
    on Oct 26, 2020
  2. added this to the 6.0.0 milestone on Oct 26, 2020
  3. pavel-orekhov commented on Dec 2, 2020

    @pavel-orekhov

    same problem was in netcoredbg
    cc @kfrolov @viewizard

  4. viewizard commented on Dec 2, 2020

    @viewizard
    Member
  5. added
    enhancementProduct code improvement that does NOT require public API changes/additions
    on Dec 9, 2020
  6. modified the milestones: 6.0.0, Future on Mar 12, 2021
  7. dotnet-policy-service commented on Sep 12, 2025

    @dotnet-policy-service
    Contributor

    Due to lack of recent activity, this issue has been marked as a candidate for backlog cleanup. It will be closed if no further activity occurs within 14 more days. Any new comment (by anyone, not necessarily the author) will undo this process.

    This process is part of our issue cleanup automation.

  8. dotnet-policy-service commented on Sep 26, 2025

    @dotnet-policy-service
    Contributor

    This issue will now be closed since it had been marked no-recent-activity but received no further activity in the past 14 days. It is still possible to reopen or comment on the issue, but please note that the issue will be locked if it remains inactive for another 30 days.

  9. removed this from the Future milestone on Sep 26, 2025
  10. locked and limited conversation to collaborators on Oct 26, 2025
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

    area-Diagnostics-coreclrenhancementProduct code improvement that does NOT require public API changes/additions

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions