You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-commits@axis.apache.org by ro...@apache.org on 2026/04/27 18:44:27 UTC

(axis-axis2-c-core) 03/03: docs: Fix fork/waitpid error handling in IPC example

This is an automated email from the ASF dual-hosted git repository.

robertlazarski pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/axis-axis2-c-core.git

commit aa0d09d84192e6b2c457703ebc721b3981b05ad0
Author: Robert Lazarski <ro...@gmail.com>
AuthorDate: Mon Apr 27 08:42:44 2026 -1000

    docs: Fix fork/waitpid error handling in IPC example
    
    The send_intent_broadcast_secure example in HTTP2_ANDROID.md was
    missing fork() failure check and waitpid() error handling. The actual
    Kanaha Camera implementation (camera_control_service.c) handles both
    correctly — update the doc example to match.
    
    Found by Gemini 2.5 Pro code review.
    
    Co-Authored-By: Claude Opus 4.6 (1M context) <no...@anthropic.com>
---
 docs/HTTP2_ANDROID.md | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/docs/HTTP2_ANDROID.md b/docs/HTTP2_ANDROID.md
index 86c47108b..146d45d0c 100644
--- a/docs/HTTP2_ANDROID.md
+++ b/docs/HTTP2_ANDROID.md
@@ -466,6 +466,13 @@ static int send_intent_broadcast_secure(
     argv[i] = NULL;
 
     pid_t pid = fork();
+
+    if (pid < 0) {
+        /* fork() failed — clean up and return error */
+        free(argv);
+        return -1;
+    }
+
     if (pid == 0) {
         /* Child process */
         execvp("/system/bin/am", argv);
@@ -473,10 +480,13 @@ static int send_intent_broadcast_secure(
     }
 
     /* Parent waits for child */
-    int status;
-    waitpid(pid, &status, 0);
     free(argv);
 
+    int status;
+    if (waitpid(pid, &status, 0) < 0) {
+        return -1;
+    }
+
     return WIFEXITED(status) && WEXITSTATUS(status) == 0 ? 0 : -1;
 }
 ```