3131 */
3232
3333#include "dmod_sal.h"
34+ #include <inttypes.h>
3435#if DMOD_USE_STDLIB
3536# include <stdlib.h>
3637#endif
@@ -67,11 +68,17 @@ DMOD_INPUT_WEAK_API_DECLARATION(Dmod, 1.0, void, _Exit, ( int Status ))
6768 * @param Context Module context to spawn
6869 * @param argc Number of arguments
6970 * @param argv Argument array
70- * @return Return value of the module or error code
71+ * @return Process ID on success (weak implementation returns DMOD_CURRENT_PROCESS_PID as placeholder),
72+ * negative error code on failure
7173 */
72- DMOD_INPUT_WEAK_API_DECLARATION (Dmod , 1.0 , int , _Spawn , ( Dmod_Context_t * Context , int argc , char * argv [ ] ))
74+ DMOD_INPUT_WEAK_API_DECLARATION (Dmod , 1.0 , Dmod_Pid_t , _Spawn , ( Dmod_Context_t * Context , int argc , char * argv [ ] ))
7375{
74- return Dmod_Run (Context , argc , argv );
76+ int result = Dmod_Run (Context , argc , argv );
77+ if (result < 0 )
78+ {
79+ return (Dmod_Pid_t )result ;
80+ }
81+ return DMOD_CURRENT_PROCESS_PID ;
7582}
7683
7784/**
@@ -83,9 +90,35 @@ DMOD_INPUT_WEAK_API_DECLARATION(Dmod, 1.0, int, _Spawn, ( Dmod_Context_t* Contex
8390 * @param Context Module context to run detached
8491 * @param argc Number of arguments
8592 * @param argv Argument array
86- * @return Return value of the module or error code
93+ * @return Process ID on success (weak implementation returns DMOD_CURRENT_PROCESS_PID as placeholder),
94+ * negative error code on failure
8795 */
88- DMOD_INPUT_WEAK_API_DECLARATION (Dmod , 1.0 , int , _RunDetached , ( Dmod_Context_t * Context , int argc , char * argv [ ] ))
96+ DMOD_INPUT_WEAK_API_DECLARATION (Dmod , 1.0 , Dmod_Pid_t , _RunDetached , ( Dmod_Context_t * Context , int argc , char * argv [ ] ))
8997{
90- return Dmod_Run (Context , argc , argv );
98+ int result = Dmod_Run (Context , argc , argv );
99+ if (result < 0 )
100+ {
101+ return (Dmod_Pid_t )result ;
102+ }
103+ return DMOD_CURRENT_PROCESS_PID ;
104+ }
105+
106+ /**
107+ * @brief Get the result of a process
108+ *
109+ * This is a weak implementation that returns 0 (success) for the current process placeholder.
110+ * The real implementation should be provided by the dmosi layer to wait for and
111+ * retrieve the exit status of a spawned process.
112+ *
113+ * @param Pid Process ID to get result for
114+ * @return Exit status of the process, or negative error code
115+ */
116+ DMOD_INPUT_WEAK_API_DECLARATION (Dmod , 1.0 , int , _GetProcessResult , ( Dmod_Pid_t Pid ))
117+ {
118+ if (Pid == DMOD_CURRENT_PROCESS_PID )
119+ {
120+ return 0 ;
121+ }
122+ DMOD_LOG_ERROR ("Dmod_GetProcessResult interface not implemented for PID %" PRId32 "\n" , Pid );
123+ return -1 ;
91124}
0 commit comments