Skip to content

Return Dmod_Pid_t from Dmod_Spawn/Dmod_RunDetached, add Dmod_GetProcessResult#214

Merged
JohnAmadis merged 5 commits intodevelopfrom
copilot/fix-dmod-spawn-return-type
Feb 13, 2026
Merged

Return Dmod_Pid_t from Dmod_Spawn/Dmod_RunDetached, add Dmod_GetProcessResult#214
JohnAmadis merged 5 commits intodevelopfrom
copilot/fix-dmod-spawn-return-type

Conversation

Copy link
Contributor

Copilot AI commented Feb 13, 2026

Process spawning functions returned int (exit code), conflating process identity with process result. Separated concerns: return PID from spawn, query result separately.

API Changes

  • New type: Dmod_Pid_t (int32_t) represents process IDs. Positive = PID, negative = error code.
  • Return type change: Dmod_Spawn() and Dmod_RunDetached() now return Dmod_Pid_t instead of int
  • New API: Dmod_GetProcessResult(Dmod_Pid_t) retrieves exit status for a given PID

Implementation

  • Weak implementations return DMOD_CURRENT_PROCESS_PID (1) when falling back to in-process execution
  • Dmod_GetProcessResult() stub returns success for placeholder PID, error otherwise
  • Real implementations (dmosi layer) will spawn actual processes and track results
// Before
int result = Dmod_Spawn(context, argc, argv);
// result was exit code, no way to track spawned process

// After
Dmod_Pid_t pid = Dmod_Spawn(context, argc, argv);
if (pid > 0) {
    int result = Dmod_GetProcessResult(pid);  // Query result separately
}

Callers in Dmod_SpawnModule() and Dmod_RunModuleDetached() cast back to int for compatibility, but now return PIDs as documented.

Original prompt

This section details on the original issue you should resolve

<issue_title>Dmod_Spawn i Dmod_RunDetached powinny zwracać Dmod_Pid_t</issue_title>
<issue_description>Aktualnie zwracają int jako result, a powinny zwracać Dmod_Pid_t (process ID). Dodaj też SAL API do odczytywania result na podstawie PID</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 4 commits February 13, 2026 15:29
Co-authored-by: JohnAmadis <17320783+JohnAmadis@users.noreply.github.com>
Co-authored-by: JohnAmadis <17320783+JohnAmadis@users.noreply.github.com>
Co-authored-by: JohnAmadis <17320783+JohnAmadis@users.noreply.github.com>
Co-authored-by: JohnAmadis <17320783+JohnAmadis@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix Dmod_Spawn and Dmod_RunDetached to return Dmod_Pid_t Return Dmod_Pid_t from Dmod_Spawn/Dmod_RunDetached, add Dmod_GetProcessResult Feb 13, 2026
Copilot AI requested a review from JohnAmadis February 13, 2026 15:35
@JohnAmadis JohnAmadis marked this pull request as ready for review February 13, 2026 15:53
@JohnAmadis JohnAmadis merged commit 5093824 into develop Feb 13, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dmod_Spawn i Dmod_RunDetached powinny zwracać Dmod_Pid_t

2 participants