File pacemaker-libservices-pipe-error-handling.patch of Package pacemaker.3577

commit 84e1b59bedb28021cee701144b30020abc5256c8
Author: NAKAHIRA Kazutomo <nakahira@intellilink.co.jp>
Date:   Thu Feb 18 15:26:19 2016 +0900

    Fix: libservices: Add error handling for pipe() failed.
    libservices have no error handling for pipe() failed.
    If pipe() succeed for standard output and pipe() failed for error output, then command in the resource agent receive SIGPIPE when output to standard output.
    It seems that resource operation have to fail explicitly when pipe() failed occurred because it raise weird error in the resource agent.

diff --git a/lib/services/services_linux.c b/lib/services/services_linux.c
index 2e1a846..d74b4db 100644
--- a/lib/services/services_linux.c
+++ b/lib/services/services_linux.c
@@ -650,11 +650,30 @@ services_os_action_execute(svc_action_t * op, gboolean synchronous)
     }
 
     if (pipe(stdout_fd) < 0) {
-        crm_err("pipe() failed");
+        int rc = errno;
+
+        crm_err("pipe(stdout_fd) failed. '%s': %s (%d)", op->opaque->exec, pcmk_strerror(rc), rc);
+
+        services_handle_exec_error(op, rc);
+        if (!synchronous) {
+            return operation_finalize(op);
+        }
+        return FALSE;
     }
 
     if (pipe(stderr_fd) < 0) {
-        crm_err("pipe() failed");
+        int rc = errno;
+
+        close(stdout_fd[0]);
+        close(stdout_fd[1]);
+
+        crm_err("pipe(stderr_fd) failed. '%s': %s (%d)", op->opaque->exec, pcmk_strerror(rc), rc);
+
+        services_handle_exec_error(op, rc);
+        if (!synchronous) {
+            return operation_finalize(op);
+        }
+        return FALSE;
     }
 
     if (synchronous) {
openSUSE Build Service is sponsored by